Submission #429775

#TimeUsernameProblemLanguageResultExecution timeMemory
429775kwongwengAncient Books (IOI17_books)C++17
0 / 100
1 ms204 KiB
#include "books.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; #define FOR(i, a, b) for(int i = a; i < b; i++) #define pb push_back long long minimum_walk(vi p, int s) { long long ans = 0; int maxi = 0; int n = p.size(); vi used(n); FOR(i, 0, n){ if (used[i]) continue; maxi = max(maxi, i); int cur = i; used[i] = 1; while (p[cur] != i){ ans += abs(p[cur] - cur); cur = p[cur]; used[cur] = 1; } ans += abs(i-cur); } ans += maxi*2; return ans; }
#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...