제출 #142847

#제출 시각아이디문제언어결과실행 시간메모리
142847babo고대 책들 (IOI17_books)C++14
0 / 100
2 ms376 KiB
#include <bits/stdc++.h> #define inf 1000000000000000000ll #define ab(x) ((x)>0?(x):-(x)) #define L long long using namespace std; L n; L chk[1000010]; L minimum_walk(vector<int>p,int s){ L i,ret=0,las=0; n=p.size(); for(i=0;i<n;i++) { if(!chk[i]&&p[i]!=i) { las=i; L temp=p[i]; ret+=ab(p[i]-i); chk[temp]=1; while(temp!=i) { ret+=ab(p[temp]-temp); temp=p[temp]; chk[temp]=1; } } } return ret+las*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...