Submission #1062505

#TimeUsernameProblemLanguageResultExecution timeMemory
1062505Sir_Ahmed_ImranAncient Books (IOI17_books)C++17
0 / 100
1 ms348 KiB
///~~~LOTA~~~/// #include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define append push_back #define add insert #define nl '\n' #define ff first #define ss second #define pii pair<int,int> #define pll pair<ll,ll> #define all(x) (x).begin(),(x).end() #define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define terminator main #define MAXN 1000000 int vis[MAXN]; ll minimum_walk(vector<int> v,int s){ ll o,r; int n,m; n=v.size(); for(int i=o=r=0;i<n;i++){ m=i; if(v[i]!=i && !vis[i]) r=i; while(!vis[m]){ o+=abs(v[m]-m); vis[m]=1; m=v[m]; } } return o+2*r; }
#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...