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