# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
602727 | 2022-07-23T10:47:49 Z | Vanilla | 곤돌라 (IOI14_gondola) | C++17 | 55 ms | 5396 KB |
#include <bits/stdc++.h> #include "gondola.h" typedef long long int64;using namespace std;int valid(int n, int a[]){map <int, int> mp;int in [n] = {};int ps = -1;for (int i = 0; i < n; i++){if (a[i] <= n) ps = i;}if (ps == -1){for (int i = 0; i < n; i++) in[i] = i + 1;}else {for (int i = ps, v = a[ps]; !in[i]; i = (i + 1) % n, v = v % n + 1) in[i] = v;}for (int i = 0; i < n; i++){mp[a[i]]++;if (mp[a[i]] > 1) return 0;}if (ps == -1) return 1;for (int i = 0; i < n; i++){if (a[i] <= n && a[i] != in[i]) return 0;}return 1;}int replacement(int n, int a[], int rs[]){const int maxv = 2e5 + 5e4;int in[n] = {};int l = 0;int ct = n + 1;int ps = -1;vector <pair <int, int> > v;for (int i = 0; i < n; i++){v.push_back({a[i], i});if (a[i] <= n) ps = i;}sort(v.begin(), v.end());if (ps == -1){for (int i = 0; i < n; i++) in[i] = i + 1;}else {for (int i = ps, v = a[ps]; !in[i]; i = (i + 1) % n, v = v % n + 1) in[i] = v;}for (auto [val, pos]: v) {while (in[pos] != val) {rs[l++] = in[pos];in[pos] = ct++;}}return l;}const int64 mod = 1e9 + 9;int64 pw (int64 a, int64 b) {if (!b) return 1;int64 h = pw (a, b / 2);return (b % 2 ? h * h % mod * a % mod: h * h % mod);}map <int, bool> is;int countReplacement(int n, int a[]){if (!valid(n, a)) return 0;bool low = 0;vector <int> v;for (int i = 0; i < n; i++){if (a[i] > n) v.push_back(a[i]);if (a[i] <= n) low = 1;}v.push_back(n);sort(v.begin(), v.end());int m = v.size();int64 rs = (low ? 1: n);for (int i = 1; i < m; i++){int64 diff = v[i] - v[i-1] - 1;rs = rs * pw(m - i, diff) % mod;}return rs;}
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 12 ms | 2260 KB | Output is correct |
7 | Correct | 12 ms | 940 KB | Output is correct |
8 | Correct | 22 ms | 4084 KB | Output is correct |
9 | Correct | 7 ms | 1492 KB | Output is correct |
10 | Correct | 30 ms | 4828 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 12 ms | 2344 KB | Output is correct |
7 | Correct | 8 ms | 996 KB | Output is correct |
8 | Correct | 23 ms | 4132 KB | Output is correct |
9 | Correct | 7 ms | 1492 KB | Output is correct |
10 | Correct | 28 ms | 4860 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 15 ms | 2132 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 40 ms | 5000 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 260 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 17 ms | 1996 KB | Output is correct |
12 | Correct | 16 ms | 2136 KB | Output is correct |
13 | Correct | 13 ms | 1332 KB | Output is correct |
14 | Correct | 14 ms | 1996 KB | Output is correct |
15 | Correct | 18 ms | 2224 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 39 ms | 4300 KB | Output is correct |
10 | Correct | 31 ms | 3676 KB | Output is correct |
11 | Correct | 11 ms | 1472 KB | Output is correct |
12 | Correct | 14 ms | 1748 KB | Output is correct |
13 | Correct | 4 ms | 672 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 43 ms | 4220 KB | Output is correct |
10 | Correct | 32 ms | 3596 KB | Output is correct |
11 | Correct | 11 ms | 1492 KB | Output is correct |
12 | Correct | 14 ms | 1708 KB | Output is correct |
13 | Correct | 3 ms | 596 KB | Output is correct |
14 | Correct | 47 ms | 4820 KB | Output is correct |
15 | Correct | 55 ms | 5396 KB | Output is correct |
16 | Correct | 9 ms | 1236 KB | Output is correct |
17 | Correct | 40 ms | 3764 KB | Output is correct |
18 | Correct | 20 ms | 2156 KB | Output is correct |