# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
235807 | 2020-05-30T01:37:30 Z | DanerZein | Gondola (IOI14_gondola) | C++14 | 1000 ms | 5752 KB |
#include "gondola.h" #include <bits/stdc++.h> #define MAX 100000000 #define mod 1000000009 using namespace std; typedef pair<int,int> ii; int valid(int n, int inputSeq[]) { set<int>s; int id,mi; mi=MAX; id=0; for(int i=0;i<n;i++){ if(mi>inputSeq[i]){ id=i; mi=inputSeq[i]; } s.insert(inputSeq[i]); } bool sw=0; int vis[100000]; memset(vis,0,sizeof vis); if(mi<=n){ // cout<<"hi"<<endl; int j=id; int aux=mi; while(true){ if(vis[j]!=0) break; if(j==n) j=0; if(aux==n+1) aux=1; if(inputSeq[j]<=n){ // cout<<inputSeq[j]<<" "<<aux<<" "<<j<<endl; if(inputSeq[j]!=aux) return 0; } vis[j]=1; j++; aux++; } //cout<<"1"<<endl; if(s.size()!=n) return 0; return 1; } if(s.size()!=n) return 0; else return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { vector<bool> nf(250010,false); vector<ii> gn; int mi=MAX,id; for(int i=0;i<n;i++){ if(mi>gondolaSeq[i]){ mi=gondolaSeq[i]; id=i; } //mi=min(mi,gondolaSeq[i]); if(gondolaSeq[i]>n){ gn.push_back(ii(gondolaSeq[i],-1)); } else{ nf[gondolaSeq[i]]=true; } } vector<int> go,gon(n,-1); if(mi>n){ for(int i=0;i<n;i++){ gon[i]=(i+1); } } else{ int j=id; int aux=mi; while(true){ if(j==gon.size()) j=0; if(gon[j]!=-1) break; gon[j]=aux; if(aux==n){ aux=0; } aux++; j++; } } int j=0; for(int i=0;i<gon.size();i++){ // cout<<gon[i]<<" "; if(nf[gon[i]]==false){ gn[j].second=gon[i]; j++; } } // cout<<endl; int ga=n+1; j=0; int t=0; sort(gn.begin(),gn.end()); /* for(int i=0;i<gn.size();i++){ cout<<gn[i]<<" "; } cout<<endl; for(int i=0;i<go.size();i++){ cout<<go[i]<<" "; } cout<<endl;*/ for(int i=0;i<gn.size();i++){ replacementSeq[j]=gn[i].second; j++; t++; while(true){ if(ga==gn[i].first){ ga++; break; } // ga++; replacementSeq[j]=ga; ga++; j++; t++; } } //cout<<t<<endl; return t; } //---------------------- int countReplacement(int n, int inputSeq[]) { //cout<<"hi"<<endl; //cout<<valid(n,inputSeq)<<endl; if(valid(n,inputSeq)){ vector<long long>gn; for(int i=0;i<n;i++){ if(inputSeq[i]>n){ gn.push_back(inputSeq[i]); } } long long gr=n+1; long long j=0; long long r=1; if(gn.size()==n) r=n; sort(gn.begin(),gn.end()); while(true){ // cout<<j<<" "<<gn.size()<<" "<<gr<<endl; if(j==gn.size()) break; if(gr==gn[j]){ gr++; j++; continue; } r=(r%mod*(gn.size()-j)%mod)%mod; gr++; } return r; } else { return 0;} }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 768 KB | Output is correct |
2 | Correct | 5 ms | 640 KB | Output is correct |
3 | Correct | 5 ms | 768 KB | Output is correct |
4 | Correct | 5 ms | 768 KB | Output is correct |
5 | Correct | 5 ms | 768 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 768 KB | Output is correct |
2 | Correct | 5 ms | 768 KB | Output is correct |
3 | Correct | 5 ms | 768 KB | Output is correct |
4 | Correct | 5 ms | 768 KB | Output is correct |
5 | Correct | 5 ms | 768 KB | Output is correct |
6 | Correct | 18 ms | 2688 KB | Output is correct |
7 | Correct | 35 ms | 4088 KB | Output is correct |
8 | Correct | 27 ms | 4352 KB | Output is correct |
9 | Correct | 11 ms | 1920 KB | Output is correct |
10 | Correct | 32 ms | 4992 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 768 KB | Output is correct |
2 | Correct | 5 ms | 640 KB | Output is correct |
3 | Correct | 5 ms | 640 KB | Output is correct |
4 | Correct | 5 ms | 768 KB | Output is correct |
5 | Correct | 5 ms | 768 KB | Output is correct |
6 | Correct | 16 ms | 2560 KB | Output is correct |
7 | Correct | 36 ms | 4088 KB | Output is correct |
8 | Correct | 26 ms | 4352 KB | Output is correct |
9 | Correct | 11 ms | 1920 KB | Output is correct |
10 | Correct | 31 ms | 4984 KB | Output is correct |
11 | Correct | 5 ms | 768 KB | Output is correct |
12 | Correct | 5 ms | 768 KB | Output is correct |
13 | Correct | 20 ms | 2432 KB | Output is correct |
14 | Correct | 5 ms | 768 KB | Output is correct |
15 | Correct | 43 ms | 5116 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 4 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 256 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 16 ms | 1024 KB | Output is correct |
12 | Correct | 17 ms | 1024 KB | Output is correct |
13 | Correct | 21 ms | 1288 KB | Output is correct |
14 | Correct | 15 ms | 1024 KB | Output is correct |
15 | Correct | 25 ms | 2296 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 768 KB | Output is correct |
2 | Correct | 5 ms | 640 KB | Output is correct |
3 | Correct | 5 ms | 768 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 768 KB | Output is correct |
2 | Correct | 5 ms | 768 KB | Output is correct |
3 | Correct | 5 ms | 768 KB | Output is correct |
4 | Correct | 5 ms | 640 KB | Output is correct |
5 | Correct | 5 ms | 768 KB | Output is correct |
6 | Correct | 5 ms | 768 KB | Output is correct |
7 | Correct | 5 ms | 768 KB | Output is correct |
8 | Correct | 5 ms | 768 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 768 KB | Output is correct |
2 | Correct | 5 ms | 768 KB | Output is correct |
3 | Correct | 5 ms | 768 KB | Output is correct |
4 | Correct | 5 ms | 768 KB | Output is correct |
5 | Correct | 5 ms | 800 KB | Output is correct |
6 | Correct | 5 ms | 768 KB | Output is correct |
7 | Correct | 5 ms | 768 KB | Output is correct |
8 | Correct | 5 ms | 768 KB | Output is correct |
9 | Correct | 44 ms | 4472 KB | Output is correct |
10 | Correct | 35 ms | 3832 KB | Output is correct |
11 | Correct | 17 ms | 1920 KB | Output is correct |
12 | Correct | 19 ms | 2048 KB | Output is correct |
13 | Correct | 10 ms | 1024 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 768 KB | Output is correct |
2 | Correct | 5 ms | 768 KB | Output is correct |
3 | Correct | 5 ms | 768 KB | Output is correct |
4 | Correct | 5 ms | 768 KB | Output is correct |
5 | Correct | 5 ms | 768 KB | Output is correct |
6 | Correct | 5 ms | 768 KB | Output is correct |
7 | Correct | 5 ms | 768 KB | Output is correct |
8 | Correct | 5 ms | 640 KB | Output is correct |
9 | Correct | 44 ms | 4472 KB | Output is correct |
10 | Correct | 35 ms | 3832 KB | Output is correct |
11 | Correct | 18 ms | 1920 KB | Output is correct |
12 | Correct | 20 ms | 2048 KB | Output is correct |
13 | Correct | 9 ms | 1024 KB | Output is correct |
14 | Execution timed out | 1094 ms | 5752 KB | Time limit exceeded |
15 | Halted | 0 ms | 0 KB | - |