This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "gondola.h"
#define st first
#define nd second
#define ii pair<int,int>
#define pb push_back
#define sz(x) (x.size())
#include<bits/stdc++.h>
using namespace std;
int find_fixed(int n,int inputSeq[]) {
int fixed=0;
for(int i=0;i<n;i++) {
if(inputSeq[i]<=n) {
fixed=i;
break ;
}
}
return fixed;
}
int valid(int n, int inputSeq[]) {
int fr[250001]={0};
int fixed=find_fixed(n,inputSeq);
int tot=2,big=0;
int cur=inputSeq[fixed];
for(int i=fixed;(tot-=(i==fixed));i=(i+1)%n,cur++) {
if(cur>n) cur-=n;
if(inputSeq[i]>n) {
fr[inputSeq[i]]++;
big++;
continue ;
}
if(inputSeq[i]!=cur) return 0;
}
for(int i=n+1;i<250001;i++) {
if(fr[i]>1) return 0;
}
return 1;
}
//----------------------
int replacement(int n, int gondolaSeq[], int replacementSeq[]) {
int fixed=find_fixed(n,gondolaSeq);
int cur=gondolaSeq[fixed];
int tot=2;
vector<ii> change;
for(int i=fixed;(tot-=(i==fixed));i=(i+1)%n,cur++) {
if(cur>n) cur-=n;
if(gondolaSeq[i]>n) {
change.pb({gondolaSeq[i],cur});
}
}
sort(change.begin(),change.end());
int sz=0;
int val=n;
for(int i=0;i<sz(change);i++) {
auto x=change[i];
replacementSeq[sz++]=x.nd;
val++;
while(val<x.st) {
replacementSeq[sz++]=val++;
}
}
return sz;
}
//----------------------
int countReplacement(int n, int inputSeq[])
{
return -3;
}
Compilation message (stderr)
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:96:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<sz(change);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... |