This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |