이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gondola.h"
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int freq[3*MAXN];
int nseq[2*MAXN];
int valid(int n, int inputSeq[])
{
// int ult = 0;
for(int i = 0; i < n; i++){
nseq[i+1] = nseq[i+n+1] = inputSeq[i];
freq[inputSeq[i]]++;
if(freq[inputSeq[i]] == 2) return 0;
}
int ini = 0, auxi = n + 1;
for(int i = 1; i <= n; i++){
if(nseq[i] <= n && nseq[i] < auxi) ini = i, auxi = nseq[i];
// printf("%d %d\n", nseq[i], auxi);
}
//printf("\n");
//printf("%d\n",ini);
if(!ini) return 1;
int ult = auxi, ultaux = ini;
for(int i = ini+1; i < ini + n; i++){
if(nseq[i] <= n){
// printf("%d %d\n", nseq[i], ult );
if(nseq[i] <= ult ||nseq[i] - ult != i - ultaux) return 0;
ult = nseq[i];
ultaux = i;
}
}
return 1;
}
//----------------------
set<pair<int, int> > s;
vector<int> v;
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
for(int i = 0; i < n; i++){
nseq[i+1] = nseq[i+n+1] = gondolaSeq[i];
freq[gondolaSeq[i]]++;
}
int ini = 0, auxi = n + 1;
for(int i = 1; i <= n; i++){
if(nseq[i] <= n && nseq[i] < auxi) ini = i, auxi = nseq[i];
//printf("%d ", nseq[i]);
}
ini = (ini - auxi + 1 > 0) ? ini-auxi+1 : n + ini -auxi + 1;
//printf("\n");
if(ini == 0) ini = 1, auxi = 1;
for(int i = ini; i <= ini + n - 1; i++){
//printf("%d %d\n", i, nseq[i]);
if(nseq[i] <= n) continue;
s.insert({nseq[i],i-ini+1});
//printf("aaan");
}
int act = n;
while(!s.empty()){
set <pair<int, int> > :: iterator it = s.begin();
v.push_back(it->second);
int f = (*s.begin()).first;
int sec = (*s.begin()).second;
s.erase({f,sec});
act++;
if(f == act) continue;
s.insert({f,act});
}
for(int i = 0; i < v.size(); i++) replacementSeq[i] = v[i];
return v.size();
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
return -3;
}
컴파일 시 표준 에러 (stderr) 메시지
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:77:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
77 | for(int i = 0; i < v.size(); i++) replacementSeq[i] = v[i];
| ~~^~~~~~~~~~
# | 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... |