답안 #610221

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
610221 2022-07-28T05:51:56 Z PiejanVDC 고대 책들 (IOI17_books) C++17
0 / 100
1 ms 296 KB
#include "books.h"
#include <bits/stdc++.h>
using namespace std;
 
long long minimum_walk(vector<int>p, int s) {
    long long last = 0;
    int n = p.size();
    long long ans = 0;
    vector<bool>vis(n,0);
    for(int i = 0 ; i < n ; i++) if(!vis[i]) {
        vis[i] = 1;
        last = i;
        int pos = i;
        do {
            vis[pos] = 1;
            int nxt = p[pos];
            p[pos] = pos;
            ans += abs(nxt-pos);
            pos = nxt;
        } while(pos != i);
    }
    return ans+2*last;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 296 KB 3rd lines differ - on the 1st token, expected: '3304', found: '4736'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '6', found: '8'
3 Halted 0 ms 0 KB -