제출 #124379

#제출 시각아이디문제언어결과실행 시간메모리
124379vex고대 책들 (IOI17_books)C++14
0 / 100
2 ms376 KiB
#include <bits/stdc++.h> #include "books.h" #define maxn 1000005 using namespace std; bool bio[maxn]; long long dfs(vector<int>p, int x) { bio[x]=true; long long tre=abs(x-p[x]); if(!bio[p[x]])tre+=dfs(p,p[x]); return tre; } long long minimum_walk(vector<int>p, int s) { int n=p.size(); for(int i=0;i<n;i++)bio[i]=false; long long sol=0LL; int last=0; for(int i=0;i<n;i++) { if(!bio[i]) { sol+=dfs(p,i); last=i; } } sol+=last; return sol; }
#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...