Submission #1025466

#TimeUsernameProblemLanguageResultExecution timeMemory
1025466huutuanAncient Books (IOI17_books)C++14
0 / 100
0 ms348 KiB
#include "books.h" #include <bits/stdc++.h> using namespace std; const int N=1e6; int vis[N], n; long long minimum_walk(vector<int> p, int s) { n=p.size(); vector<int> v; long long ans=0; int mx=0; for (int i=0; i<n; ++i) if (!vis[i]){ mx=max(mx, i); while (!vis[i]){ vis[i]=1; ans+=abs(p[i]-i); i=p[i]; } } return ans+mx*2; }
#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...