Submission #610221

# Submission time Handle Problem Language Result Execution time Memory
610221 2022-07-28T05:51:56 Z PiejanVDC Ancient Books (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;
}
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -