# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
389369 | 2021-04-14T03:41:56 Z | Pichon5 | 곤돌라 (IOI14_gondola) | C++17 | 56 ms | 9844 KB |
#include <bits/stdc++.h> #include "gondola.h" #pragma GCC optimize("O3") #define ll long long const ll M = 1e9+9; using namespace std; int valid(int n, int inputSeq[]){ set<int> seen; for(int i = 0; i < n; i++){ if(seen.count(inputSeq[i])) return 0; seen.insert(inputSeq[i]); } int pos = -1, st; for(int i = 0; i < n; i++) if(inputSeq[i] <= n) pos = i, st = inputSeq[i]; if(pos == -1) return 1; for(int j = 0; j < n; j++, pos++, pos %= n){ if(inputSeq[pos] > n) continue; if(inputSeq[pos] != (st+j-1)%n+1) return 0; } return 1; } int replacement(int n, int gondolaSeq[], int replacementSeq[]){ int l = 0, last = n, pos = -1, st; vector< pair<int, int> > q; vector<int> p(n); for(int i = 0; i < n; i++) if(gondolaSeq[i] <= n) pos = i, st = gondolaSeq[i]; if(pos == -1) for(int i = 0; i < n; i++) p[i] = i+1; else for(int i = 0; i < n; i++, pos++, pos %= n) p[pos] = (st+i-1)%n+1; for(int i = 0; i < n; i++) if(gondolaSeq[i] > n) q.push_back({gondolaSeq[i], i}); if(q.empty()) return 0; sort(q.begin(), q.end()); for(auto &t : q){ replacementSeq[l++] = p[t.second]; last++; while(last != t.first) replacementSeq[l++] = last++; } return l; } int countReplacement(int n, int inputSeq[]){ if(!valid(n, inputSeq)) return 0; vector<int> a(250001); ll s = 1, m = n; for(int i = 0; i < n; i++) a[inputSeq[i]]++; for(int i = 249999; i > n; i--) a[i] += a[i+1]; for(int i = n+1; i < 250000; i++){ if(!a[i]) break; if(a[i] == a[i+1]) s *= a[i], s %= M; } for(int i = 0; i < n; i++) if(inputSeq[i] <= n) m = 1; s *= m, s %= M; return s; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 14 ms | 2152 KB | Output is correct |
7 | Correct | 10 ms | 588 KB | Output is correct |
8 | Correct | 32 ms | 3800 KB | Output is correct |
9 | Correct | 8 ms | 1356 KB | Output is correct |
10 | Correct | 34 ms | 4416 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 14 ms | 2124 KB | Output is correct |
7 | Correct | 10 ms | 588 KB | Output is correct |
8 | Correct | 30 ms | 3884 KB | Output is correct |
9 | Correct | 8 ms | 1356 KB | Output is correct |
10 | Correct | 33 ms | 4520 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
13 | Correct | 19 ms | 2056 KB | Output is correct |
14 | Correct | 0 ms | 204 KB | Output is correct |
15 | Correct | 55 ms | 4544 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 10 ms | 868 KB | Output is correct |
12 | Correct | 12 ms | 1008 KB | Output is correct |
13 | Correct | 16 ms | 1236 KB | Output is correct |
14 | Correct | 10 ms | 844 KB | Output is correct |
15 | Correct | 23 ms | 2196 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1228 KB | Output is correct |
2 | Correct | 1 ms | 1228 KB | Output is correct |
3 | Correct | 1 ms | 1228 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1228 KB | Output is correct |
2 | Correct | 1 ms | 1228 KB | Output is correct |
3 | Correct | 1 ms | 1228 KB | Output is correct |
4 | Correct | 1 ms | 1228 KB | Output is correct |
5 | Correct | 1 ms | 1228 KB | Output is correct |
6 | Correct | 1 ms | 1228 KB | Output is correct |
7 | Correct | 1 ms | 1228 KB | Output is correct |
8 | Correct | 1 ms | 1228 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1228 KB | Output is correct |
2 | Correct | 1 ms | 1228 KB | Output is correct |
3 | Correct | 1 ms | 1228 KB | Output is correct |
4 | Correct | 1 ms | 1228 KB | Output is correct |
5 | Correct | 1 ms | 1228 KB | Output is correct |
6 | Correct | 1 ms | 1228 KB | Output is correct |
7 | Correct | 1 ms | 1228 KB | Output is correct |
8 | Correct | 1 ms | 1232 KB | Output is correct |
9 | Correct | 42 ms | 4480 KB | Output is correct |
10 | Correct | 35 ms | 4676 KB | Output is correct |
11 | Correct | 14 ms | 2480 KB | Output is correct |
12 | Correct | 16 ms | 2856 KB | Output is correct |
13 | Correct | 5 ms | 1612 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1228 KB | Output is correct |
2 | Correct | 1 ms | 1228 KB | Output is correct |
3 | Correct | 1 ms | 1228 KB | Output is correct |
4 | Correct | 1 ms | 1228 KB | Output is correct |
5 | Correct | 1 ms | 1232 KB | Output is correct |
6 | Correct | 1 ms | 1232 KB | Output is correct |
7 | Correct | 1 ms | 1228 KB | Output is correct |
8 | Correct | 1 ms | 1228 KB | Output is correct |
9 | Correct | 44 ms | 4400 KB | Output is correct |
10 | Correct | 36 ms | 4672 KB | Output is correct |
11 | Correct | 14 ms | 2508 KB | Output is correct |
12 | Correct | 16 ms | 2808 KB | Output is correct |
13 | Correct | 5 ms | 1612 KB | Output is correct |
14 | Runtime error | 56 ms | 9844 KB | Execution killed with signal 11 |
15 | Halted | 0 ms | 0 KB | - |