# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
250686 | 2020-07-18T17:37:28 Z | hhh07 | 곤돌라 (IOI14_gondola) | C++14 | 30 ms | 2804 KB |
#include <iostream> #include <vector> #include <algorithm> #include <queue> #include <utility> #include <set> #include <cmath> #include <climits> #include <cstring> #include <stdio.h> #include <assert.h> #include "gondola.h" using namespace std; typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; ll MOD = 1e9 + 9; ll stepen(ll x, int st){ ll res = 1; while(st > 0){ if (st&1) res = (1LL)*(res*x)%MOD; x = (1LL)*(x*x)%MOD; st /= 2; } return res; } int valid(int n, int x[]){ int j = -1; for (int i = 0; i < n; i++){ if (x[i] > n) continue; j = i; break; } for (int i = 0; i < n; i++){ if (j > i){ int moze = x[j] - (j - i); if (moze < 1) moze += n; if (x[i] <= n && moze != x[i]){ return false; } } else{ int moze = x[j] + (i - j); if (moze > n) moze -= n; if (x[i] <= n && moze != x[i]){ return false; } } } sort(x, x + n); for (int i = 1; i < n; i++) if (x[i] == x[i - 1]) return false; return true; } int replacement(int n, int x[], int y[]){ vector<ii> t; int j = 0; for (int i = 0; i < n; i++){ if (x[i] > n) t.push_back(make_pair(x[i], i)); else j = i; } sort(t.begin(), t.end()); if (t.size() == n) x[0] = 1; for (int i = 0; i < n; i++){ if (j > i){ int moze = x[j] - (j - i); if (moze < 1) moze += n; x[i] = moze; } else{ int moze = x[j] + (i - j); if (moze > n) moze -= n; x[i] = moze; } } vi res; int k = n; for (int i = 0; i < t.size(); i++){ int curr = t[i].first, idx = t[i].second; res.push_back(x[idx]); for (int j = k + 1; j < curr; j++) res.push_back(j); k = curr; } for (int i = 0; i < res.size(); i++) y[i] = res[i]; return res.size(); } int countReplacement(int n, int x[]){ bool k = valid(n, x); if (!k) return 0; vi t; for (int i = 0; i < n; i++) if (x[i] > n) t.push_back(x[i]); sort(t.begin(), t.end()); ll res = 1; int prev = n; for (int i = 0; i < t.size(); i++){ res *= stepen(t.size() - i, t[i] - prev - 1); res = res%MOD; prev = t[i]; } if (t.size() == n){ res *= n; res = res%MOD; } return res; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 256 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 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 256 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 | 8 ms | 512 KB | Output is correct |
7 | Correct | 15 ms | 768 KB | Output is correct |
8 | Correct | 13 ms | 640 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 18 ms | 640 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 1 ms | 256 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 | 8 ms | 512 KB | Output is correct |
7 | Correct | 13 ms | 640 KB | Output is correct |
8 | Correct | 13 ms | 640 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 17 ms | 640 KB | Output is correct |
11 | Correct | 0 ms | 256 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 6 ms | 512 KB | Output is correct |
14 | Correct | 0 ms | 256 KB | Output is correct |
15 | Correct | 14 ms | 640 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 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 | 0 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 | 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 | 256 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 1 ms | 512 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 512 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 | 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 | 1 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 512 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 512 KB | Output is correct |
11 | Correct | 17 ms | 640 KB | Output is correct |
12 | Correct | 16 ms | 640 KB | Output is correct |
13 | Correct | 17 ms | 2040 KB | Output is correct |
14 | Correct | 11 ms | 640 KB | Output is correct |
15 | Correct | 25 ms | 2804 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 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 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 | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 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 | 0 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 20 ms | 1276 KB | Output is correct |
10 | Correct | 17 ms | 1148 KB | Output is correct |
11 | Correct | 6 ms | 768 KB | Output is correct |
12 | Correct | 8 ms | 872 KB | Output is correct |
13 | Correct | 2 ms | 512 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 | 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 | 1 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 19 ms | 1276 KB | Output is correct |
10 | Correct | 16 ms | 1148 KB | Output is correct |
11 | Correct | 7 ms | 844 KB | Output is correct |
12 | Correct | 9 ms | 768 KB | Output is correct |
13 | Correct | 2 ms | 512 KB | Output is correct |
14 | Correct | 26 ms | 1784 KB | Output is correct |
15 | Correct | 30 ms | 2800 KB | Output is correct |
16 | Correct | 6 ms | 896 KB | Output is correct |
17 | Correct | 20 ms | 1908 KB | Output is correct |
18 | Correct | 11 ms | 1532 KB | Output is correct |