이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include"gondola.h"
#include<bits/stdc++.h>
//#include"grader.cpp"
using namespace std;
int valid(int n,int a[]){
int i=0,need;
while(i<n&&a[i]>n)i++;
need=a[i];
while(i<n){
if(a[i]<=n&&a[i]!=need)return 0;
if(need==n)need=1;
else need++;
i++;
}
sort(a,a+n);
for(i=1;i<n;i++)if(a[i]==a[i-1])return 0;
return 1;
}
int pos[250005];
int replacement(int n,int a[],int res[]){
vector<pair<int,int>>b;
int i=0,ind=n,need=1,len=0,mx=0;
while(i<n&&a[i]>n)i++;
if(i!=n)need=a[i]-i;
if(need<1)need+=n;
for(i=0;i<n;i++,need=need%n+1)b.push_back({a[i],need}),mx=max(mx,a[i]);
sort(b.begin(),b.end());
i=0;
while(i+1<n){
if(b[i].first<=n){
i++;
continue;
}
res[len++]=b[i].second;
b[i].first=++ind;
while(b[i].first<b[i+1].first){
res[len++]=b[i].first;
b[i].first=++ind;
}
i++;
}
if(mx>n){
res[len++]=b[i].second;
b[i].first=++ind;
while(b[i].first<mx){
res[len++]=b[i].first;
b[i].first=++ind;
}
i++;
}
return len;
}
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... |