이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include<algorithm>
using namespace std;
int a[100010],ch[250010],visit[250010];
struct data
{
int x,y;
bool operator<(const data&r)const
{
return x<r.x;
}
}arr[250010];
int valid(int n, int inputSeq[])
{
int i,k=0;
for(i=0;i<n;i++)
{
if(visit[inputSeq[i]]==1) return 0;
visit[inputSeq[i]]=1;
if(inputSeq[i]<=n) ch[inputSeq[i]]=i+1;
}
for(i=1;i<=n;i++)
{
if(ch[i]!=0 && k==0)
{
k=ch[i];
continue;
}
if(k!=0)
{
k++;
if(k>n) k=1;
}
if(ch[i]!=0 && k!=ch[i]) return 0;
}
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
int s,i,big=0,k=1,w=0,top=0,pos,p;
for(i=0;i<n;i++)
{
ch[gondolaSeq[i]]=i;
if(gondolaSeq[i]<=n) visit[i]=1;
if(big<gondolaSeq[i]) big=gondolaSeq[i];
if(gondolaSeq[i]<=n) pos=i,p=gondolaSeq[i];
}
for(i=0;i<n;i++)
{
if(visit[i]==0)
{
top++;
arr[top].x=gondolaSeq[i];
arr[top].y=i;
}
}
sort(arr+1,arr+top+1);
for(i=pos;i<=pos+n-1;i++)
{
a[i%n]=p;
p++;
if(p==n+1) p=1;
}
for(i=n+1;i<=big;i++)
{
if(ch[i]==0)
{
replacementSeq[w++]=a[arr[k].y];
a[arr[k].y]=i;
}
else
{
replacementSeq[w++]=a[arr[k].y];
a[arr[k].y]=i;
k++;
}
}
return w;
}
//----------------------
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... |