# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
425501 | 2021-06-13T06:05:53 Z | Charis02 | Ancient Books (IOI17_books) | C++14 | 2000 ms | 204 KB |
#include "books.h" #include<iostream> #include<vector> #include<map> #define ll long long #define rep(i,a,b) for(int i = a;i < b;i++) #define mp(a,b) make_pair(a,b) #define N 100003 using namespace std; bool vis[N]; int abso(int x) { return (x < 0) ? -x : x; } ll get_cycle_cost(vector < int > c) { if(c.size()==1) return 0; ll res = 0; rep(i,1,c.size()) { res += abso(c[i]-c[i-1]); } res += abso(c[0]-c[c.size()-1]); return res; } long long minimum_walk(std::vector<int> p, int s) // for 1st sub { int n = p.size(); int misplaced = 0; int cur = 0; int holding = -1; rep(i,0,n) { if(p[i] != i) misplaced++; } ll ans = -1; bool dpos = true; while(true) { ans++; if(p[cur] != cur) { int tmp = holding; holding = p[cur]; p[cur] = tmp; if(p[cur] == cur) misplaced--; } if(misplaced == 0) break; if(dpos && cur == n-1) dpos = false; if(!dpos && cur == 0) dpos = true; if(dpos) cur++; else cur--; } ans += cur; return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Incorrect | 1 ms | 204 KB | 3rd lines differ - on the 1st token, expected: '8', found: '18' |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Incorrect | 1 ms | 204 KB | 3rd lines differ - on the 1st token, expected: '8', found: '18' |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Incorrect | 1 ms | 204 KB | 3rd lines differ - on the 1st token, expected: '8', found: '18' |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2080 ms | 204 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Incorrect | 1 ms | 204 KB | 3rd lines differ - on the 1st token, expected: '8', found: '18' |
4 | Halted | 0 ms | 0 KB | - |