Submission #53099

#TimeUsernameProblemLanguageResultExecution timeMemory
53099zetapiGondola (IOI14_gondola)C++14
25 / 100
15 ms1660 KiB
#include "gondola.h" #include "bits/stdc++.h" using namespace std; const int MAX=1e6; const int mod=1e9; int arr[MAX],fre[MAX]; int valid(int n, int inputSeq[]) { int N=n,ok=1; for(int A=0;A<N;A++) { fre[inputSeq[A]]++; if(fre[inputSeq[A]]>1) return 0; } for(int A=0;A<N;A++) { if(inputSeq[A]<=N) { ok=0; inputSeq[A]--; for(int B=A;B>=0;B--) { arr[B]=inputSeq[A]; inputSeq[A]--; if(inputSeq[A]<0) inputSeq[A]+=N; } inputSeq[A]=arr[A]; for(int B=A+1;B<N;B++) { inputSeq[A]++; if(inputSeq[A]>=N) inputSeq[A]=0; arr[B]=inputSeq[A]; } inputSeq[A]=arr[A]+1; break; } } if(ok) return 1; for(int A=0;A<N;A++) arr[A]++; for(int A=0;A<N;A++) { if(inputSeq[A]<=N and arr[A]!=inputSeq[A]) return 0; } return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { return -2; } //---------------------- int countReplacement(int n, int inputSeq[]) { if(!valid(n,inputSeq)) return 0; int res=1; for(int A=0;A<n;A++) { if(inputSeq[A]>n+1) { res*=(inputSeq[A]-n-1); res%=mod; } } for(int A=0;A<n;A++) { if(inputSeq[A]<=n) break; if(A==n-1) { res*=n; res%=mod; } } return res; } /*int main() { ios_base::sync_with_stdio(false); int arr[]={1,2,7,6}; cout<<countReplacement(4,arr); return 0; }*/
#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...