Submission #892313

#TimeUsernameProblemLanguageResultExecution timeMemory
892313abcvuitunggioAncient Books (IOI17_books)C++17
0 / 100
0 ms444 KiB
#include "books.h" #include <bits/stdc++.h> using namespace std; int vis[1000001]; long long minimum_walk(vector <int> p, int s){ int x=0,n=p.size(); long long d=0; for (int i=0;i<n;i++){ if (!vis[i]){ x=i; while (true){ vis[x]=1; d+=abs(x-p[x]); x=p[x]; if (x==i) break; } } } return x*2+d; }
#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...