# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
521287 | 2022-02-01T13:36:06 Z | sofapuden | 곤돌라 (IOI14_gondola) | C++14 | 59 ms | 5956 KB |
#include "gondola.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; const int M = 1e9+9; ll pw(ll a, ll b){ ll r = 1; while(b){ if(b&1)r = r*a%M; b>>=1; a = a*a%M; } return r; } int valid(int n, int inputSeq[]){ set<int> S; int x = 0; for(int i = 0; i < n; ++i){ if(S.count(inputSeq[i]))return 0; S.insert(inputSeq[i]); if(inputSeq[i] <= n)x = (inputSeq[i]-i+n-1)%(n)+1; } for(int i = 0; i < n; ++i){ if(inputSeq[i] != (x+i-1)%(n)+1 && inputSeq[i] <= n)return 0; } return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]){ vector<pair<int,int>> v; int x = 1; for(int i = 0; i < n; ++i){ if(gondolaSeq[i] <= n)x = (gondolaSeq[i]-i+n-1)%(n)+1; } for(int i = 0; i < n; ++i){ if(gondolaSeq[i] > n){ v.emplace_back(gondolaSeq[i],(x+i-1)%n+1); } } sort(v.begin(),v.end()); int cn = 0; for(int i = 0; i < v.size(); ++i){ replacementSeq[cn++] = v[i].second; while(cn + n < v[i].first){ replacementSeq[cn] = cn+n; cn++; } } return cn; } //---------------------- int countReplacement(int n, int gondolaSeq[]){ if(!valid(n,gondolaSeq))return 0; vector<ll> v; bool ok = 0; for(int i = 0; i < n; ++i){ if(gondolaSeq[i] > n){ v.emplace_back((ll)gondolaSeq[i]); } else ok = 1; } sort(v.begin(),v.end()); ll z = v.size(); if(z == 0)return 1; ll ans = pw(z,v[0]-n-1); for(int i = 1; i < z; ++i){ ans = (ans * pw(z-i,v[i]-v[i-1]-1)) % M; } if(!ok)ans = (ans*n)%M; return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 12 ms | 2124 KB | Output is correct |
7 | Correct | 7 ms | 596 KB | Output is correct |
8 | Correct | 23 ms | 3916 KB | Output is correct |
9 | Correct | 7 ms | 1356 KB | Output is correct |
10 | Correct | 30 ms | 4500 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 12 ms | 2148 KB | Output is correct |
7 | Correct | 7 ms | 588 KB | Output is correct |
8 | Correct | 23 ms | 3848 KB | Output is correct |
9 | Correct | 8 ms | 1356 KB | Output is correct |
10 | Correct | 29 ms | 4508 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 0 ms | 204 KB | Output is correct |
13 | Correct | 16 ms | 1996 KB | Output is correct |
14 | Correct | 0 ms | 204 KB | Output is correct |
15 | Correct | 37 ms | 4632 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 0 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 1 ms | 332 KB | Output is correct |
11 | Correct | 7 ms | 488 KB | Output is correct |
12 | Correct | 8 ms | 588 KB | Output is correct |
13 | Correct | 14 ms | 1244 KB | Output is correct |
14 | Correct | 7 ms | 588 KB | Output is correct |
15 | Correct | 17 ms | 2244 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 0 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 0 ms | 204 KB | Output is correct |
8 | Correct | 0 ms | 204 KB | Output is correct |
9 | Correct | 35 ms | 3956 KB | Output is correct |
10 | Correct | 28 ms | 3404 KB | Output is correct |
11 | Correct | 15 ms | 1436 KB | Output is correct |
12 | Correct | 15 ms | 1684 KB | Output is correct |
13 | Correct | 3 ms | 588 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 0 ms | 204 KB | Output is correct |
8 | Correct | 0 ms | 204 KB | Output is correct |
9 | Correct | 46 ms | 4112 KB | Output is correct |
10 | Correct | 28 ms | 3292 KB | Output is correct |
11 | Correct | 10 ms | 1428 KB | Output is correct |
12 | Correct | 12 ms | 1636 KB | Output is correct |
13 | Correct | 3 ms | 588 KB | Output is correct |
14 | Correct | 47 ms | 5436 KB | Output is correct |
15 | Correct | 59 ms | 5956 KB | Output is correct |
16 | Correct | 10 ms | 1288 KB | Output is correct |
17 | Correct | 35 ms | 4116 KB | Output is correct |
18 | Correct | 19 ms | 2732 KB | Output is correct |