Submission #118290

#TimeUsernameProblemLanguageResultExecution timeMemory
118290tinjyuAncient Books (IOI17_books)C++14
0 / 100
2 ms384 KiB
#include "books.h" #include <bits/stdc++.h> using namespace std; bool tag[1000005]; int a[1000005]; long long int ans,now; int find(int x) { ans+=abs(x-a[x]); if(tag[x]==1)return 0; tag[x]=1; find(a[x]); } long long minimum_walk(std::vector<int> p, int s) { int n=p.size(); for(int i=0;i<n;i++)a[i]=p[i]; int t=0; for(int i=0;i<n;i++) { if(tag[i]==0) { now=i; tag[i]=1; find(a[i]); if(a[i]!=i)t=max(t,i); } } ans+=t+t; return ans; }

Compilation message (stderr)

books.cpp: In function 'int find(int)':
books.cpp:14:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#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...