# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1023520 | 2024-07-14T23:21:56 Z | HappyCapybara | Ancient Books (IOI17_books) | C++17 | 1 ms | 348 KB |
#include "books.h" #include<bits/stdc++.h> using namespace std; #define ll long long vector<int> par, siz; int find(int a){ if (par[a] == a) return a; return par[a] = find(par[a]); } void merge(int a, int b){ a = find(a); b = find(b); if (a == b) return; else par[a] = b; siz[b] += siz[a]; siz[a] = 0; } ll minimum_walk(vector<int> p, int s){ int n = p.size(); par.resize(n); siz.resize(n, 1); for (int i=0; i<n; i++) par[i] = i; for (int i=0; i<n; i++) merge(i, p[i]); int res = -2; for (int i=0; i<n; i++){ res += abs(p[i]-i); if (siz[i] > 1) res += 2; } if (siz[0] = 1) res += 2; return res; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Incorrect | 0 ms | 348 KB | 3rd lines differ - on the 1st token, expected: '8', found: '10' |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Incorrect | 0 ms | 348 KB | 3rd lines differ - on the 1st token, expected: '8', found: '10' |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Incorrect | 0 ms | 348 KB | 3rd lines differ - on the 1st token, expected: '8', found: '10' |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | 3rd lines differ - on the 1st token, expected: '3304', found: '3108' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Incorrect | 0 ms | 348 KB | 3rd lines differ - on the 1st token, expected: '8', found: '10' |
4 | Halted | 0 ms | 0 KB | - |