Submission #160959

#TimeUsernameProblemLanguageResultExecution timeMemory
160959InfiniteJestGondola (IOI14_gondola)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <fstream> #include <vector> #include <queue> #include <algorithm> #include <math.h> #define pb push_back #define mp make_pair #define fi first #define se second using namespace std; ifstream in("input.txt"); ofstream out("output.txt"); int valid(int n, int inputSeq[]){ int ans=1; for(int i=0;i<n;i++){ if(inputSeq[i]<=n){ int val=inputSeq[i]; for(int y=0;y<n;y++){ if(inputSeq[i]<=n&&inputSeq[(i+y)%n]!=val){ ans=0; break; } val++; if(val==n+1)val=1; } break; } } return ans; } int replacement(int n, int gondolaSeq[], int replacementSeq[]){ bool flag=0; vector<pair<int,int> > p; int ind=-1,val; for(int i=0;i<n;i++){ if(inputSeq[i]<=n){ ind=i; val=inputSeq[i]; } else flag=1; } if(!flag)return 0; if(ind==-1){ ind=0; val=1; } for(int i=0;i<n;i++){ if(inputSeq[(ind+i)%n]>n){ flag=1; p.pb(mp(inputSeq[(ind+i)],val)); } val++; } sort(p.begin(),p.end()); int cur=n+1; int indtot=0; for(int i=0;i<p.size();i++){ replacementSeq[indtot++]=p[i].se; for(;cur<p[i].fi;cur++)replacementSeq[indtot++]=cur; cur+=2; } }

Compilation message (stderr)

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:40:10: error: 'inputSeq' was not declared in this scope
       if(inputSeq[i]<=n){
          ^~~~~~~~
gondola.cpp:52:10: error: 'inputSeq' was not declared in this scope
       if(inputSeq[(ind+i)%n]>n){
          ^~~~~~~~
gondola.cpp:61:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<p.size();i++){
                 ~^~~~~~~~~
gondola.cpp:66:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^