Submission #467091

#TimeUsernameProblemLanguageResultExecution timeMemory
467091julian33Ancient Books (IOI17_books)C++14
0 / 100
1 ms304 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #define deb(...) logger(#__VA_ARGS__, __VA_ARGS__) template<typename ...Args> void logger(string vars, Args&&... values) { cerr<<vars<<" = "; string delim=""; (...,(cerr<<delim<<values,delim=", ")); cerr<<"\n"; } #else #define deb(...) logger(#__VA_ARGS__, __VA_ARGS__) template<typename ...Args> void logger(string vars, Args&&... values) {} #endif #define pb push_back #define sz(x) (int)(x.size()) typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; template<typename T> inline void maxa(T& a,T b){a=max(a,b);} template<typename T> inline void mina(T& a,T b){a=min(a,b);} mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int mxN=2e5+5; //make sure this is right const int mod=1e9+7; long long minimum_walk(vector<int> p, int s){ int n=sz(p); ll ans=0; int most=0; for(int i=0;i<n;i++){ if(p[i]==i) continue; most=i; int k=p[i]; int idx=i; while(p[idx]!=i){ ans++; if(p[idx]>k) swap(k,p[idx]); idx++; } swap(k,p[idx]); ans+=idx-i; } return ans+2*most; }
#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...