제출 #576885

#제출 시각아이디문제언어결과실행 시간메모리
576885mosiashvililuka곤돌라 (IOI14_gondola)C++14
75 / 100
20 ms4004 KiB
#include "gondola.h" #include<bits/stdc++.h> using namespace std; long long a,b,c,d,e,i,j,ii,jj,zx,xc,f[300009],fx[300009],pi,ee,WA,pas,mod=1000000009LL; int valid(int Nn, int inputSeq[]) { a=Nn; for(i=1; i<=a; i++) f[i]=inputSeq[i-1]; set <int> SAE; for(i=1; i<=a; i++){ if(f[i]<=a){ c=f[i]-i+a*2;c%=a; SAE.insert(c); } } if(SAE.size()>=2) return 0; for(i=1; i<=a; i++){ if(fx[f[i]]!=0) return 0; fx[f[i]]=1; } return 1; } //---------------------- int replacement(int Nn, int gondolaSeq[], int replacementSeq[]) { a=Nn;WA=1; for(i=1; i<=a; i++){ f[i]=gondolaSeq[i-1]; } for(i=1; i<=a; i++){ if(f[i]>a){ fx[f[i]]=i; if(e<f[i]){ e=f[i];ee=i; } }else{ WA=f[i]-i; } } for(i=1; i<=a; i++){ f[i]=WA+i+a*3;f[i]%=a; if(f[i]==0) f[i]=a; } for(i=a+1; i<=e; i++){ if(fx[i]==0){ replacementSeq[pi]=/*ee*/f[ee]; f[ee]=i; }else{ c=fx[i]; replacementSeq[pi]=/*fx[i]*/f[c]; } pi++; } return pi; } //---------------------- int countReplacement(int Nn, int inputSeq[]) { a=Nn; for(i=1; i<=a; i++) f[i]=inputSeq[i-1]; set <int> SAE; for(i=1; i<=a; i++){ if(f[i]<=a){ c=f[i]-i+a*2;c%=a; SAE.insert(c); } } if(SAE.size()>=2) return 0; for(i=1; i<=a; i++){ if(fx[f[i]]!=0) return 0; fx[f[i]]=1; } for(i=0; i<=300003; i++) fx[i]=0; pas=1; for(i=1; i<=a; i++){ if(f[i]>a){ fx[f[i]]++; } } for(i=300000; i>=1; i--){ fx[i]+=fx[i+1]; } e=0; for(i=1; i<=a; i++) e=max(e,f[i]); if(e==a) return 1; for(i=a+1; i<=e; i++){ if(fx[i]!=fx[i+1]){ }else{ pas*=fx[i];pas%=mod; } } return pas; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...