#include <bits/stdc++.h>
using namespace std;
int valid(int n, int inputSeq[]){
bool ss = 0;
int ind = 0 , val = 0;
for(int i = 0;i<n;i++){
if(inputSeq[i]<=n){
ss = 1;
val = inputSeq[i]-1;
ind = i;
}
}
if(!ss)return 1;
for(int i = ind+1;i<n;i++){
val++;
val%=n;
if(inputSeq[i]<=n){
if((inputSeq[i]-1)!=val)return 0;
}
}
for(int i = 0;i<ind;i++){
val++;val%=n;
if(inputSeq[i]<=n){
if((inputSeq[i]-1)!=val)return 0;
}
}
return 1;
}int replacement(int n, int gondolaSeq[], int replacementSeq[]){
vector<pair<int,int>> v;
int ind = 0, val = 0;bool ss = 0;
for(int i = 0;i<n;i++){
if(gondolaSeq[i]<=n){
ind = i;val = gondolaSeq[i]-1;
ss = 1;
}
}
int lol[n];
if(ss){
lol[ind] = val;
for(int i = ind+1;i<n;i++){
val++;
val%=n;
lol[i] = val;
}
for(int i = 0;i<ind;i++){
val++;val%=n;
lol[i] = val;
}
}
for(int i = 0;i<n;i++){
if(gondolaSeq[i]>n){
v.push_back({gondolaSeq[i],(ss==0?i+1:lol[i]+1)});
}
}
sort(v.begin(),v.end());
int l = n+1;
int st =0;
for(int i = 0;i<v.size();i++){
replacementSeq[st++] = v[i].second;
++l;
while(l<=v[i].first){
replacementSeq[st++] = l-1;
l++;
}
}
return st;
}
/*
int main(){
int S[] = {10, 4, 3, 11, 12};
cout<<valid(6,S);
}*/
Compilation message
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:59:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
59 | for(int i = 0;i<v.size();i++){
| ~^~~~~~~~~
/usr/bin/ld: /tmp/ccJQTpCi.o: in function `main':
grader.cpp:(.text.startup+0xb6): undefined reference to `valid'
/usr/bin/ld: grader.cpp:(.text.startup+0x108): undefined reference to `countReplacement'
/usr/bin/ld: grader.cpp:(.text.startup+0x132): undefined reference to `replacement'
collect2: error: ld returned 1 exit status