이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
int con[250005]={0};
int all[100005];
set < int > have;
vector < pair < int , int > > how ;
int valid(int n, int inputSeq[])
{
int what,ok=1,i;
for(i=1;i<=n;i++) all[i]=1e9;
for(i=0;i<n;i++)
{
con[inputSeq[i]]++;
if(con[inputSeq[i]]>=2) ok=0;
if(inputSeq[i]>n) continue;
all[inputSeq[i]]=(inputSeq[i]-i+n)%n;
what=(inputSeq[i]-i+n)%n;
}
for(i=1;i<=n;i++) if(all[i]!=1000000000&&all[i]!=what) ok=0;
return ok;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
int now=0,con=0,where=0,big=0,t,i;
for(i=0;i<n;i++)
{
if(gondolaSeq[i]>n) con++;
else where=i;
big=max(big,gondolaSeq[i]);
}
for(i=1;i<=big;i++) have.insert(i);
for(i=0;i<n;i++)
{
have.erase(gondolaSeq[(where+i)%n]);
if(gondolaSeq[(where+i)%n]>n&&gondolaSeq[(where+i)%n]<=n+con)
{
t=(gondolaSeq[where]+i)%n;
if(t==0) t=n;
how.push_back(make_pair(gondolaSeq[(where+i)%n],t));
have.erase(t);
}
}
sort(how.begin(),how.end());
for(auto i:how) replacementSeq[now++]=i.second;
for(auto i:have) replacementSeq[now++]=i;
return now;
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
return -3;
}
컴파일 시 표준 에러 (stderr) 메시지
gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:23:44: warning: 'what' may be used uninitialized in this function [-Wmaybe-uninitialized]
23 | for(i=1;i<=n;i++) if(all[i]!=1000000000&&all[i]!=what) ok=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... |