이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
int valid(int n, int inputSeq[]){
vector<bool> seen(250002,false);
int mnv = 250002;
int mnind = -1;
for (int i = 0; i<n; i++){
if (seen[inputSeq[i]]){
return 0;
}
seen[inputSeq[i]]=true;
if (mnv>inputSeq[i]){
mnv=inputSeq[i];
mnind=i;
}
}
if (mnv>n){
return 1;
}
mnv++;
for (int i = (mnind+1)%n; i!=mnind; i=(i+1)%n){
if (1<=inputSeq[i]&&inputSeq[i]<=n){
if (mnv!=inputSeq[i]){
return 0;
}
}
mnv++;
}
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[]){
vector<pair<int,int>> gondind;
int oneind = 0;
for (int i = 0; i<n; i++){
if (gondolaSeq[i]<n){
oneind=(i+n-(gondolaSeq[i]-1))%n;
break;
}
}
for (int i = 0; i<n; i++){
if (gondolaSeq[i]>=n){
gondind.push_back({gondolaSeq[i],1+(i-oneind+n)%n});
}
}
sort(gondind.begin(),gondind.end());
int ptr = 0;
int gprev = n;
int lastplaced = n;
for (auto g : gondind){
//cout<<g.first<<" "<<g.second<<'\n';
replacementSeq[ptr]=g.second;
ptr++;
lastplaced++;
for (int h = gprev+1; h<g.first; h++){
replacementSeq[ptr]=lastplaced;
ptr++;
lastplaced++;
}
gprev=g.first;
}
return ptr;
}
//----------------------
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... |