# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
422842 | 2021-06-10T13:00:08 Z | APROHACK | Gondola (IOI14_gondola) | C++14 | 75 ms | 5068 KB |
#include "gondola.h" #include <bits/stdc++.h> #define PB push_back #define S second #define F first using namespace std; int valid(int n, int inputSeq[]) { set<int>ocurr; /* for(int i = 0 ; i < 250001 ; i++){ ocurr[i]=false; }*/ //bool pst=false; int cur=-1; for(int i = 0 ; i < n ; i++){ if((ocurr.find(inputSeq[i]))!=ocurr.end()){ return 0; } ocurr.insert(inputSeq[i]); if(inputSeq[i]<=n){ if(cur==-1){ cur=inputSeq[i]; }else{ if(inputSeq[i]!=cur)return 0; } } if(cur!=-1)cur++; if(cur==n+1)cur=1; } return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { int pos=-1; vector<pair<int, int> >wow; int mascara[n]; for(int i = 0 ; i < n ; i++){ if(gondolaSeq[i]>n){ wow.PB({gondolaSeq[i], i}); }else{ pos=i; } } int cur=gondolaSeq[pos]; for(int i = pos ; i >=0 ; i--){ mascara[i]=cur; cur--; if(cur==0)cur=n; } cur=gondolaSeq[pos]; for(int i = pos ; i <n ; i++){ mascara[i]=cur; cur++; if(cur==n+1)cur=1; } int l, p=n+1, indx=0; sort(wow.begin(), wow.end());//numero, indice for(int i = 0 ; i < wow.size(); i++){ while(mascara[wow[i].S]<wow[i].F){ replacementSeq[indx]=mascara[wow[i].S]; mascara[wow[i].S]=p; //cout<<replacementSeq[indx]<<endl; p++; indx++; } } return indx; } //---------------------- long long pot(long long bas, long long exp){ if(exp==1)return bas; if(exp==0)return 1; long long ret=pot(bas, exp/2); if(exp%2==0)return (ret*ret)%1000000009; return (((ret*ret)%1000000009)*bas)%1000000009; } int countReplacement(int n, int inputSeq[]) { if(valid(n, inputSeq)==0)return 0; vector<long long >whew; long long mxcur=n; bool fixed=false; for(int i = 0 ; i < n ; i++){ if(inputSeq[i]>n){ whew.PB(inputSeq[i]); }else{ fixed=true; } } long long rta = 1, MOD = 1000000009; sort(whew.begin(), whew.end()); for(int i = 0 ; i < whew.size() ; i++){ long long nxt=(whew[i]), nums; nums=(nxt-1)-(mxcur); if(nums!=0&&(whew.size()-i)>1)rta*=pot((whew.size()-i), nums)%MOD; rta%=MOD; mxcur=nxt; //wow.pop(); } if(!fixed){ rta*=n; rta%=MOD; } return rta; }
Compilation message
# | Verdict | Execution time | Memory | 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 | 0 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 15 ms | 2180 KB | Output is correct |
7 | Correct | 10 ms | 644 KB | Output is correct |
8 | Correct | 36 ms | 3880 KB | Output is correct |
9 | Correct | 9 ms | 1356 KB | Output is correct |
10 | Correct | 39 ms | 4504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 1 ms | 204 KB | Output is correct |
6 | Correct | 15 ms | 2108 KB | Output is correct |
7 | Correct | 11 ms | 604 KB | Output is correct |
8 | Correct | 30 ms | 3876 KB | Output is correct |
9 | Correct | 9 ms | 1464 KB | Output is correct |
10 | Correct | 36 ms | 4468 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 0 ms | 204 KB | Output is correct |
13 | Correct | 5 ms | 332 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 10 ms | 588 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 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 |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 2 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 332 KB | Output is correct |
10 | Correct | 2 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | 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 | 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 | 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 | 9 ms | 844 KB | Output is correct |
12 | Correct | 11 ms | 972 KB | Output is correct |
13 | Correct | 23 ms | 1300 KB | Output is correct |
14 | Correct | 10 ms | 832 KB | Output is correct |
15 | Correct | 23 ms | 2304 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 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 | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 57 ms | 4004 KB | Output is correct |
10 | Correct | 38 ms | 3276 KB | Output is correct |
11 | Correct | 14 ms | 1388 KB | Output is correct |
12 | Correct | 16 ms | 1688 KB | Output is correct |
13 | Correct | 3 ms | 588 KB | Output is correct |
# | Verdict | Execution time | Memory | 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 | 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 | 1 ms | 204 KB | Output is correct |
9 | Correct | 54 ms | 4012 KB | Output is correct |
10 | Correct | 39 ms | 3292 KB | Output is correct |
11 | Correct | 13 ms | 1484 KB | Output is correct |
12 | Correct | 16 ms | 1612 KB | Output is correct |
13 | Correct | 4 ms | 588 KB | Output is correct |
14 | Correct | 63 ms | 4432 KB | Output is correct |
15 | Correct | 75 ms | 5068 KB | Output is correct |
16 | Correct | 10 ms | 1100 KB | Output is correct |
17 | Correct | 66 ms | 3520 KB | Output is correct |
18 | Correct | 24 ms | 2340 KB | Output is correct |