# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
272750 | 2020-08-18T15:04:22 Z | toonewbie | 곤돌라 (IOI14_gondola) | C++17 | 59 ms | 6008 KB |
#include "gondola.h" #include <bits/stdc++.h> using namespace std; #define F first #define S second const int N = 100005; const int MOD = 1000000009; int valid(int n, int A[]) { set <int> S(A, A + n); if (S.size() != n) return 0; for (int i = 0, k = -MOD; i < n; i++) { if (A[i] <= n) { if (k == -MOD) k = (A[i] - i - 1 + n) % n; else if (k != (A[i] - i - 1 + n) % n) return 0; } } return 1; } int replacement(int n, int A[], int ret[]) { int k = -MOD, ptr = 0; vector <int> B(N); for (int i = 0; i < n; i++) { if (A[i] <= n) { k = (A[i] - i - 1 + n) % n; } } vector <pair <int, int>> v; for(int i = 0; i < n; i++) { if (k == -MOD) B[i] = A[i]; else B[i] = A[(i - k + n) % n]; if (B[i] > n) v.push_back({B[i], i + 1}); } sort(v.begin(), v.end()); for (int i = 0; i < v.size(); i++) { while (ptr + n < v[i].F) { ret[ptr++] = v[i].S; v[i].S = ptr + n; } } return ptr; } int modpow(int a, int b) { int ret = 1; for (; b; b >>= 1) { if (b & 1) ret = 1LL * ret * a % MOD; a = 1LL * a * a % MOD; } return ret; } int countReplacement(int n, int A[]) { if (!valid(n, A)) return 0; vector <int> v; for (int i = 0; i < n; i++) if(A[i] > n) v.push_back(A[i]); sort (v.begin(), v.end()); int ans = 1; for (int i = 0; i < v.size(); i++) { int b = v.size() - i; int p = v[i] - (i ? v[i - 1] + 1 : n + 1); ans = 1LL * ans * modpow(b, p) % MOD; } if (v.size() == n) ans = 1LL * ans * n % MOD; return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 10 ms | 2432 KB | Output is correct |
7 | Correct | 32 ms | 4216 KB | Output is correct |
8 | Correct | 24 ms | 4352 KB | Output is correct |
9 | Correct | 6 ms | 1536 KB | Output is correct |
10 | Correct | 22 ms | 5076 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 416 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 12 ms | 2432 KB | Output is correct |
7 | Correct | 32 ms | 4224 KB | Output is correct |
8 | Correct | 25 ms | 4352 KB | Output is correct |
9 | Correct | 6 ms | 1664 KB | Output is correct |
10 | Correct | 27 ms | 4992 KB | Output is correct |
11 | Correct | 1 ms | 256 KB | Output is correct |
12 | Correct | 1 ms | 384 KB | Output is correct |
13 | Correct | 21 ms | 2296 KB | Output is correct |
14 | Correct | 1 ms | 384 KB | Output is correct |
15 | Correct | 48 ms | 5248 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 768 KB | Output is correct |
2 | Correct | 1 ms | 768 KB | Output is correct |
3 | Correct | 1 ms | 768 KB | Output is correct |
4 | Correct | 1 ms | 768 KB | Output is correct |
5 | Correct | 1 ms | 768 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 768 KB | Output is correct |
2 | Correct | 1 ms | 768 KB | Output is correct |
3 | Correct | 1 ms | 768 KB | Output is correct |
4 | Correct | 1 ms | 768 KB | Output is correct |
5 | Correct | 1 ms | 768 KB | Output is correct |
6 | Correct | 1 ms | 768 KB | Output is correct |
7 | Correct | 1 ms | 768 KB | Output is correct |
8 | Correct | 2 ms | 768 KB | Output is correct |
9 | Correct | 1 ms | 800 KB | Output is correct |
10 | Correct | 2 ms | 768 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 768 KB | Output is correct |
2 | Correct | 1 ms | 768 KB | Output is correct |
3 | Correct | 1 ms | 768 KB | Output is correct |
4 | Correct | 1 ms | 768 KB | Output is correct |
5 | Correct | 1 ms | 768 KB | Output is correct |
6 | Correct | 1 ms | 768 KB | Output is correct |
7 | Correct | 1 ms | 768 KB | Output is correct |
8 | Correct | 1 ms | 768 KB | Output is correct |
9 | Correct | 1 ms | 768 KB | Output is correct |
10 | Correct | 1 ms | 768 KB | Output is correct |
11 | Correct | 11 ms | 1536 KB | Output is correct |
12 | Correct | 13 ms | 1664 KB | Output is correct |
13 | Correct | 17 ms | 1660 KB | Output is correct |
14 | Correct | 11 ms | 1536 KB | Output is correct |
15 | Correct | 25 ms | 2416 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 48 ms | 4600 KB | Output is correct |
10 | Correct | 32 ms | 3832 KB | Output is correct |
11 | Correct | 12 ms | 1664 KB | Output is correct |
12 | Correct | 15 ms | 1920 KB | Output is correct |
13 | Correct | 5 ms | 640 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 1 ms | 256 KB | Output is correct |
9 | Correct | 42 ms | 4632 KB | Output is correct |
10 | Correct | 32 ms | 3832 KB | Output is correct |
11 | Correct | 12 ms | 1664 KB | Output is correct |
12 | Correct | 15 ms | 1920 KB | Output is correct |
13 | Correct | 4 ms | 640 KB | Output is correct |
14 | Correct | 51 ms | 5368 KB | Output is correct |
15 | Correct | 59 ms | 6008 KB | Output is correct |
16 | Correct | 11 ms | 1408 KB | Output is correct |
17 | Correct | 40 ms | 4216 KB | Output is correct |
18 | Correct | 24 ms | 2552 KB | Output is correct |