이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "gondola.h"
using namespace std;
set<int> visited;
int valid(int n,int input[]){
for(int i=0;i<n;i++)
if(visited.find(input[i])!=visited.end())
return 0;
else
visited.insert(input[i]);
int start = -1;
for(int i=0;i<n;i++)if(input[i]<=n){
start = i;
break;
}
if(start==-1)return 1;
int next = input[start];
int pos = start;
for(int i=0;i<n;i++){
if(input[pos]<=n&&input[pos]!=next)return 0;
pos++;
if(pos>=n)pos=0;
next++;
if(next>n)next=1;
}
return 1;
}
int replacement(int n, int gondolaSeq[], int replacementSeq[]){
int start = 0;
for(int i=0;i<n;i++){
if(gondolaSeq[i]<=n){start = i;break;}
}
int next = gondolaSeq[start]<=n?gondolaSeq[start]:1;
vector<pair<int,int>> vec;
int pos = 0;
for(int i=0;i<n;i++){
vec.push_back({gondolaSeq[pos++],next++});
if(next>n)next = 1;
if(pos>=n)pos=0;
}
sort(vec.begin(),vec.end());
int last = n;
int l = 0;
for(int i=0;i<n;i++){
while(vec.at(i).first != vec.at(i).second){
replacementSeq[l++] = vec.at(i).second;
vec.at(i).second = ++last;
}
}
return l;
}
int countReplacement(int n, int inputSeq[]){
return 0;
}
# | 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... |