# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
249840 | 2020-07-16T03:16:39 Z | ant101 | 곤돌라 (IOI14_gondola) | C++14 | 69 ms | 6008 KB |
#include <bits/stdc++.h> #include "gondola.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 | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 256 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 | 0 ms | 384 KB | Output is correct |
6 | Correct | 11 ms | 2432 KB | Output is correct |
7 | Correct | 33 ms | 4224 KB | Output is correct |
8 | Correct | 25 ms | 4344 KB | Output is correct |
9 | Correct | 7 ms | 1664 KB | Output is correct |
10 | Correct | 22 ms | 4992 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 384 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 | 33 ms | 4216 KB | Output is correct |
8 | Correct | 25 ms | 4472 KB | Output is correct |
9 | Correct | 6 ms | 1536 KB | Output is correct |
10 | Correct | 21 ms | 4992 KB | Output is correct |
11 | Correct | 0 ms | 256 KB | Output is correct |
12 | Correct | 1 ms | 384 KB | Output is correct |
13 | Correct | 17 ms | 2304 KB | Output is correct |
14 | Correct | 0 ms | 256 KB | Output is correct |
15 | Correct | 41 ms | 5244 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 |
# | 결과 | 실행 시간 | 메모리 | 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 |
# | 결과 | 실행 시간 | 메모리 | 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 | 17 ms | 1536 KB | Output is correct |
12 | Correct | 15 ms | 1664 KB | Output is correct |
13 | Correct | 17 ms | 1660 KB | Output is correct |
14 | Correct | 13 ms | 1536 KB | Output is correct |
15 | Correct | 22 ms | 2412 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 | 1 ms | 384 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 |
4 | Correct | 0 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 | 256 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 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 | 0 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 41 ms | 4472 KB | Output is correct |
10 | Correct | 32 ms | 3840 KB | Output is correct |
11 | Correct | 12 ms | 1536 KB | Output is correct |
12 | Correct | 15 ms | 1920 KB | Output is correct |
13 | Correct | 3 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 | 384 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 43 ms | 4520 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 | 59 ms | 5496 KB | Output is correct |
15 | Correct | 69 ms | 6008 KB | Output is correct |
16 | Correct | 10 ms | 1408 KB | Output is correct |
17 | Correct | 40 ms | 4216 KB | Output is correct |
18 | Correct | 21 ms | 2560 KB | Output is correct |