# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
374531 | 2021-03-07T11:10:08 Z | Aryan_Raina | 곤돌라 (IOI14_gondola) | C++14 | 74 ms | 6140 KB |
#include "gondola.h" #include <bits/stdc++.h> using namespace std; #define ll long long const ll MOD = 1e9+9; int valid(int n, int a[]) { int rr = -1; set<int> vis; for (int i = 0; i < n; i++) { if (vis.count(a[i])) return 0; vis.insert(a[i]); if (a[i] <= n) { if (rr == -1) rr = i; if ((n + a[i] - a[rr]) % n != (n + i - rr) % n) return 0; } } return 1; } //---------------------- int replacement(int n, int a[], int replacementSeq[]) { int rr = -1; for (int i = 0; i < n; i++) { if (a[i] <= n) { rr = i; break; } } vector<array<int,2>> rep; for (int i = 0; i < n; i++) { if (a[i] > n) { int x = (a[rr] + i - rr + n) % n; if (x == 0) x = n; rep.push_back({a[i], x}); } } sort(rep.begin(), rep.end()); int ind = 0, last = n+1; for (int i = 0; i < rep.size(); ++i) { replacementSeq[ind++] = rep[i][1]; last++; for (; last <= rep[i][0]; ++last) replacementSeq[ind++] = last-1; } return ind; } //---------------------- ll modpow(ll a, ll b) { ll res = 1; while (b) { if (b & 1) res = (res * a)%MOD; a = (a * a)%MOD; b>>=1; } return res; } int countReplacement(int n, int a[]) { if (!valid(n, a)) return 0; vector<int> rep; for (int i = 0; i < n; i++) { if (a[i] > n) { rep.push_back(a[i]); } } sort(rep.begin(), rep.end()); ll ans = 1, last = n+1; int sz = rep.size(); for (int i = 0; i < sz; i++) { ans = (ans * modpow(sz-i, rep[i] - last)) % MOD; last = rep[i]+1; } if (rep.size() == n) { ans = (ans * n) % MOD; } return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 0 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 0 ms | 364 KB | Output is correct |
5 | Correct | 0 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 0 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 14 ms | 2284 KB | Output is correct |
7 | Correct | 11 ms | 620 KB | Output is correct |
8 | Correct | 31 ms | 4076 KB | Output is correct |
9 | Correct | 8 ms | 1516 KB | Output is correct |
10 | Correct | 35 ms | 4568 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 380 KB | Output is correct |
6 | Correct | 14 ms | 2284 KB | Output is correct |
7 | Correct | 11 ms | 620 KB | Output is correct |
8 | Correct | 31 ms | 3948 KB | Output is correct |
9 | Correct | 9 ms | 1516 KB | Output is correct |
10 | Correct | 35 ms | 4588 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 6 ms | 492 KB | Output is correct |
14 | Correct | 0 ms | 364 KB | Output is correct |
15 | Correct | 11 ms | 620 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 0 ms | 364 KB | Output is correct |
4 | Correct | 0 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 0 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 0 ms | 364 KB | Output is correct |
6 | Correct | 0 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 10 ms | 620 KB | Output is correct |
12 | Correct | 11 ms | 620 KB | Output is correct |
13 | Correct | 16 ms | 1276 KB | Output is correct |
14 | Correct | 10 ms | 620 KB | Output is correct |
15 | Correct | 26 ms | 2276 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 0 ms | 364 KB | Output is correct |
5 | Correct | 0 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 61 ms | 4076 KB | Output is correct |
10 | Correct | 37 ms | 3436 KB | Output is correct |
11 | Correct | 13 ms | 1516 KB | Output is correct |
12 | Correct | 18 ms | 1772 KB | Output is correct |
13 | Correct | 4 ms | 748 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 0 ms | 364 KB | Output is correct |
4 | Correct | 0 ms | 364 KB | Output is correct |
5 | Correct | 0 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 50 ms | 4204 KB | Output is correct |
10 | Correct | 37 ms | 3436 KB | Output is correct |
11 | Correct | 13 ms | 1516 KB | Output is correct |
12 | Correct | 17 ms | 1772 KB | Output is correct |
13 | Correct | 4 ms | 620 KB | Output is correct |
14 | Correct | 60 ms | 5356 KB | Output is correct |
15 | Correct | 74 ms | 6140 KB | Output is correct |
16 | Correct | 11 ms | 1388 KB | Output is correct |
17 | Correct | 44 ms | 4204 KB | Output is correct |
18 | Correct | 23 ms | 2540 KB | Output is correct |