# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
153281 | 2019-09-13T07:39:50 Z | arnold518 | Gondola (IOI14_gondola) | C++14 | 37 ms | 2552 KB |
#include "gondola.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1e5; const ll MOD = 1e9+9; int valid(int N, int *A) { int i, j; vector<int> S(A, A+N); sort(S.begin(), S.end()); S.erase(unique(S.begin(), S.end()), S.end()); if(S.size()!=N) return 0; int flag=-1; for(i=0; i<N; i++) { if(A[i]>N) continue; int t=(A[i]-1-i+N)%N; if(flag==-1) flag=t; else if(flag!=t) return 0; } return 1; } int replacement(int N, int *A, int *B) { int i, j, ret=0; int flag=0; vector<pii> V; for(i=0; i<N; i++) { if(A[i]<=N) { flag=(A[i]-1-i+N)%N; continue; } V.push_back({A[i], i}); } for(i=0; i<N; i++) A[i]=(i+flag)%N+1; sort(V.begin(), V.end()); int now=N+1; for(i=0; i<V.size(); i++) { int p=V[i].first, q=V[i].second; while(A[q]!=p) { B[ret++]=A[q]; A[q]=now++; } } return ret; } ll mypow(ll x, ll y) { if(y==0) return 1; if(y%2) return mypow(x, y-1)*x%MOD; ll ret=mypow(x, y/2); return ret*ret%MOD; } int countReplacement(int N, int *A) { int i, j; ll ans=1; if(!valid(N, A)) return 0; int flag=-1; vector<int> V; V.push_back(N); for(i=0; i<N; i++) { if(A[i]<=N) flag=0; else V.push_back(A[i]); } sort(V.begin(), V.end()); for(i=1; i<V.size(); i++) ans=ans*mypow(V.size()-i, V[i]-V[i-1]-1)%MOD; if(flag==-1) ans=ans*N%MOD; return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 3 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 10 ms | 632 KB | Output is correct |
7 | Correct | 20 ms | 1016 KB | Output is correct |
8 | Correct | 14 ms | 888 KB | Output is correct |
9 | Correct | 7 ms | 504 KB | Output is correct |
10 | Correct | 20 ms | 1016 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 10 ms | 632 KB | Output is correct |
7 | Correct | 20 ms | 1016 KB | Output is correct |
8 | Correct | 14 ms | 888 KB | Output is correct |
9 | Correct | 7 ms | 504 KB | Output is correct |
10 | Correct | 20 ms | 1016 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 10 ms | 632 KB | Output is correct |
14 | Correct | 2 ms | 256 KB | Output is correct |
15 | Correct | 21 ms | 1016 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 380 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 404 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 3 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 252 KB | Output is correct |
8 | Correct | 3 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 3 ms | 376 KB | Output is correct |
11 | Correct | 12 ms | 632 KB | Output is correct |
12 | Correct | 13 ms | 632 KB | Output is correct |
13 | Correct | 18 ms | 1300 KB | Output is correct |
14 | Correct | 12 ms | 632 KB | Output is correct |
15 | Correct | 24 ms | 2196 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 252 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 380 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 3 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 25 ms | 1100 KB | Output is correct |
10 | Correct | 20 ms | 1020 KB | Output is correct |
11 | Correct | 9 ms | 632 KB | Output is correct |
12 | Correct | 11 ms | 632 KB | Output is correct |
13 | Correct | 5 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 25 ms | 1096 KB | Output is correct |
10 | Correct | 22 ms | 1016 KB | Output is correct |
11 | Correct | 10 ms | 632 KB | Output is correct |
12 | Correct | 11 ms | 632 KB | Output is correct |
13 | Correct | 6 ms | 376 KB | Output is correct |
14 | Correct | 33 ms | 2340 KB | Output is correct |
15 | Correct | 37 ms | 2552 KB | Output is correct |
16 | Correct | 8 ms | 760 KB | Output is correct |
17 | Correct | 25 ms | 1648 KB | Output is correct |
18 | Correct | 13 ms | 1248 KB | Output is correct |