Submission #566320

#TimeUsernameProblemLanguageResultExecution timeMemory
566320TemmieAncient Books (IOI17_books)C++17
0 / 100
1 ms212 KiB
//#include "public_c/public/cpp/books.h" #include "books.h" #include <bits/stdc++.h> long long minimum_walk(std::vector <int> p, int s) { int n = p.size(); std::vector <bool> vis(n, false); int big = 0; long long ans = 0; for (int i = 0; i < n; i++) { if (vis[i]) { continue; } vis[i] = true; big = i; int u = i; do { ans += abs(p[u] - u); u = p[u]; vis[u] = true; } while (u != i); } ans += big * 2; return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...