Submission #161288

#TimeUsernameProblemLanguageResultExecution timeMemory
161288DavidDamianGondola (IOI14_gondola)C++11
20 / 100
15 ms1604 KiB
#include "gondola.h" #include<iostream> ///Determine weather a sequence is valid ///Construct a replacement sequence ///Count the number of replacement sequences using namespace std; int bucket[250005]; int findFirst (int n,int A[]){ ///Finds the first element in the arrar less or equal to n for(int i=0;i<n;i++){ if(A[i]<=n) return i; } return -1; } int valid(int n, int inputSeq[]) { int id=findFirst(n,inputSeq); for(int i=0;i<n;i++){ if(bucket[ inputSeq[i] ]==1) //Checks every element to not be repeated return 0; bucket[inputSeq[i]]=1; } if(id==-1) //If there are no repeated elements and all elemets are greater than n, the sequence is valid return 1; int x=inputSeq[id]; for(int i=0;i<n;i++){ //Otherwise checks for each element if it is the same than expected (x) if(inputSeq[(id+i)%n]<=n) if(inputSeq[(id+i)%n]!=x) return 0; x++; if(x==n+1) x=1; } return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { return -2; } //---------------------- int countReplacement(int n, int inputSeq[]) { return -3; }
#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...