Submission #288753

# Submission time Handle Problem Language Result Execution time Memory
288753 2020-09-01T20:58:50 Z peti1234 Ancient Books (IOI17_books) C++17
0 / 100
1 ms 384 KB
#include <bits/stdc++.h>

using namespace std;
const int c=100002;
bool v[c];
long long sum;
int n, t[c], mini, maxi;
void dfs(int a) {
    v[a]=true;
    mini=min(mini, a);
    if (!v[t[a]]) dfs(t[a]);
}
long long minimum_walk(vector<int> p, int s) {
    n=p.size();
    for (int i=0; i<n; i++) t[i]=p[i], sum+=(abs(p[i]-i));
    for (int i=0; i<n; i++) if (!v[i] && t[i]!=i) mini=n, dfs(i), maxi=max(maxi, mini);
    return sum+2*maxi;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Incorrect 0 ms 384 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Incorrect 0 ms 384 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Incorrect 0 ms 384 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB 3rd lines differ - on the 1st token, expected: '3304', found: '4728'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Incorrect 0 ms 384 KB 3rd lines differ - on the 1st token, expected: '8', found: '10'
7 Halted 0 ms 0 KB -