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 <bits/stdc++.h>
#include "gondola.h"
using namespace std;
/**********************/
int valid(int n, int inputSeq[])
{
int preval = -1;
for(int i =0; i<n; i++){
//cout << preval<<endl;
if(preval == -1){
if(inputSeq[i] <= n)
preval = inputSeq[i];
continue;
}
if(inputSeq[i] <=n){
if(preval == n){
if(inputSeq[i] != 1) return false;
}
else
if(inputSeq[i]!= preval+1) return false;
preval = inputSeq[i];
}
else{
//replacement, num can be anything
if(preval == n)
preval = 1;
else preval++;
}
}
if(inputSeq[n-1] == n)
return inputSeq[0] == 1;
else return inputSeq[n-1] +1 == inputSeq[0];
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
int preval = -1;
for(int i =n -1; i>=0; i--){
if(gondolaSeq[i] <=n) preval = (n - i -1) + gondolaSeq[i];
}
if(preval == -1){
//all of them were replaced
for(int i = 0; i<n; i++){
replacementSeq[i] = i+1;
}
return n;
}
int cnt = 0;
for(int i =0; i<n; i++){
if(gondolaSeq[i] <=n){
preval = gondolaSeq[i];
}
else{
//replacement, num can be anything
if(preval == n){
replacementSeq[cnt] = 1;
}
else {
replacementSeq[cnt] = ++preval;
}
cnt++;
}
}
return cnt;
}
//----------------------
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... |