Submission #1075690

#TimeUsernameProblemLanguageResultExecution timeMemory
1075690edogawa_somethingAncient Books (IOI17_books)C++17
50 / 100
84 ms15968 KiB
#include "books.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vii; typedef pair<ll,ll> pii; #define F first #define S second #define all(v) v.begin(),v.end() #define pb push_back ll n; bool vis[2000000]; long long minimum_walk(vector<int> p, int s) { n=p.size(); ll res=0; bool chk=1; for(int i=0;i<n;i++) { if(p[i]!=i) chk=0; } if(chk) return 0; ll cnt=0; for(int i=0;i<n;i++) { if(p[i]>=i) { cnt++; } vis[p[i]]=1; if(vis[i]) cnt--; res+=2*cnt; if(cnt==0) res+=2; } res-=2; for(int i=n-1;i>=0;i--) { if(p[i]==i) res-=2; else break; } return res; }
#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...