이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |