# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
66422 | 2018-08-10T13:57:21 Z | Kubalionzzale | 곤돌라 (IOI14_gondola) | C++14 | 22 ms | 1268 KB |
#include "gondola.h" #include <iostream> #include <algorithm> int valid(int n, int a[]) { bool visited[250010] = { 0 }; int remember = -1; for (int i = 0; i < n; ++i) { --a[i]; if (visited[a[i]]) return 0; else visited[a[i]] = 1; if (a[i] < n) { if (remember == -1) remember = i; else { int val1 = a[remember]; int val2 = a[i]; if (val1 > val2) { if (remember == (i + (val1 - val2)) % n) continue; else return 0; } else { if (i == (remember + (val2 - val1)) % n) continue; else return 0; } } } } return 1; } //---------------------- int replacement(int n, int a[], int ans[]) { int model[100010] = { 0 }; int diff = -1; bool visited[250010] = { 0 }; int max = 0; for (int i = 0; i < n; ++i) { if (a[i] <= n) { --a[i]; diff = (i - a[i] + n) % n; ++a[i]; } visited[a[i]] = true; if (a[i] > max) max = a[i]; } if (max == n) return 0; int cnt = max - n; int returning = cnt; --cnt; int lastunused = max - 1; while (visited[lastunused]) { --lastunused; } for (int i = 0; i < n; ++i) { if (a[i] <= n) continue; if (lastunused <= n) { a[i] = (i + diff) % n; ++a[i]; ans[cnt] = a[i]; --cnt; if (cnt == -1) return returning; } else { while (lastunused > n) { a[i] = lastunused; ans[cnt] = lastunused; --cnt; --lastunused; while (visited[lastunused]) { --lastunused; } } a[i] = (i + diff) % n; ++a[i]; ans[cnt] = a[i]; --cnt; if (cnt == -1) return returning; } } return returning; } //---------------------- int countReplacement(int n, int inputSeq[]) { return -3; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 612 KB | Output is correct |
3 | Correct | 3 ms | 776 KB | Output is correct |
4 | Correct | 2 ms | 776 KB | Output is correct |
5 | Correct | 2 ms | 776 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 776 KB | Output is correct |
2 | Correct | 3 ms | 776 KB | Output is correct |
3 | Correct | 3 ms | 776 KB | Output is correct |
4 | Correct | 3 ms | 792 KB | Output is correct |
5 | Correct | 3 ms | 852 KB | Output is correct |
6 | Correct | 7 ms | 992 KB | Output is correct |
7 | Correct | 14 ms | 1124 KB | Output is correct |
8 | Correct | 11 ms | 1124 KB | Output is correct |
9 | Correct | 5 ms | 1124 KB | Output is correct |
10 | Correct | 12 ms | 1124 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1124 KB | Output is correct |
2 | Correct | 2 ms | 1124 KB | Output is correct |
3 | Correct | 2 ms | 1124 KB | Output is correct |
4 | Correct | 3 ms | 1124 KB | Output is correct |
5 | Correct | 2 ms | 1124 KB | Output is correct |
6 | Correct | 8 ms | 1132 KB | Output is correct |
7 | Correct | 15 ms | 1148 KB | Output is correct |
8 | Correct | 12 ms | 1148 KB | Output is correct |
9 | Correct | 6 ms | 1148 KB | Output is correct |
10 | Correct | 13 ms | 1268 KB | Output is correct |
11 | Correct | 3 ms | 1268 KB | Output is correct |
12 | Correct | 3 ms | 1268 KB | Output is correct |
13 | Correct | 8 ms | 1268 KB | Output is correct |
14 | Correct | 3 ms | 1268 KB | Output is correct |
15 | Correct | 22 ms | 1268 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 1268 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 1268 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 1268 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 1268 KB | Integer -3 violates the range [0, 1000000008] |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 1268 KB | Integer -3 violates the range [0, 1000000008] |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 1268 KB | Integer -3 violates the range [0, 1000000008] |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 1268 KB | Integer -3 violates the range [0, 1000000008] |
2 | Halted | 0 ms | 0 KB | - |