# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
68731 | 2018-08-18T09:51:54 Z | Talant | Ancient Books (IOI17_books) | C++17 | 2 ms | 364 KB |
#include "books.h" //#include "grader.cpp" #include <bits/stdc++.h> #define sc second #define fr first #define mk make_pair #define pb push_back using namespace std; const int N = (1e6 + 5); const int inf = (1e9 + 7); int f; int cur = -1,id; int u[N]; int ans; long long minimum_walk(vector<int> p, int s) { for (int i = 0; i < p.size(); i ++) u[p[i]] = i; for (int i = p.size() - 1; i >= 0; i --) { if (p[i] != i) { if (cur == i) { ans += abs(i - id); swap(cur,p[i]); id = i; } else { ans += abs(u[i] - id) + abs(u[i] - i); if (cur != -1) swap(p[u[i]],cur); cur = i; swap(cur,p[i]); id = i; } } } return (ans + id); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 248 KB | 3rd lines differ - on the 1st token, expected: '6', found: '8' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 248 KB | 3rd lines differ - on the 1st token, expected: '6', found: '8' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 248 KB | 3rd lines differ - on the 1st token, expected: '6', found: '8' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 364 KB | 3rd lines differ - on the 1st token, expected: '3304', found: '4814' |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 248 KB | 3rd lines differ - on the 1st token, expected: '6', found: '8' |
2 | Halted | 0 ms | 0 KB | - |