답안 #610238

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
610238 2022-07-28T06:02:00 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);
    int mx = -1;
    for(int i = 0 ; i < n ; i++) if(!vis[i]) {
        vis[i] = 1;
        if(i > mx)
            last = i;
        int pos = i;
        do {
            vis[pos] = 1;
            mx = max(mx, pos);
            int nxt = p[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 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 0 ms 296 KB 3rd lines differ - on the 1st token, expected: '4', found: '10'
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 0 ms 296 KB 3rd lines differ - on the 1st token, expected: '4', found: '10'
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 0 ms 296 KB 3rd lines differ - on the 1st token, expected: '4', found: '10'
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 216 KB 3rd lines differ - on the 1st token, expected: '3304', found: '2744'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 0 ms 296 KB 3rd lines differ - on the 1st token, expected: '4', found: '10'
6 Halted 0 ms 0 KB -