Submission #376780

#TimeUsernameProblemLanguageResultExecution timeMemory
376780lakshith_Gondola (IOI14_gondola)C++14
Compilation error
0 ms0 KiB
#include "gondola.h" #include <bits/stdc++.h> using namespace std; bool b[2500010]; int checkOnce(int n,int vec[]){ for(int i=0;i<n;i++) if(b[vec[i]])return 0; else b[vec[i]]=true; return 1; } int valid(int n, int vec[]) { if(!checkOnce(n,vec))return 0; int MIN=INT_MAX,minI=0; for(int i=0;i<n;i++)if(MIN>vec[i])MIN=vec[i],minI=i; int p = MIN; int pos = minI; if(MIN>n)return 1; for(int k=0;k<n;k++){ if(vec[pos]<=n && vec[pos]!=p)return 0; pos++; p++; pos%=n; } return 1; } int replacement(int n, int gondolaSeq[], int replacementSeq[]) { int start = 0; for(int i=0;i<n;i++){ if(gondolaSeq[i]<=n){start = i;break;} } int next = gondolaSeq[start]<=n?gondolaSeq[start]:1; vector<pair<int,int>> vec; int pos = start; for(int i=0;i<n;i++){ x[i] = {gondolaSeq[pos],next}; pos++; next++; if(next>n)next = 1; if(pos>=n)pos=0; } sort(x,x+n); int last = n; int l = 0; for(int i=0;i<n;i++){ while(x[i].first != x[i].second){ replacementSeq[l++] = x[i].second; x[i].second = ++last; } } return l; } //---------------------- int countReplacement(int n, int inputSeq[]) { return -3; }

Compilation message (stderr)

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:42:3: error: 'x' was not declared in this scope
   42 |   x[i] = {gondolaSeq[pos],next};
      |   ^
gondola.cpp:48:9: error: 'x' was not declared in this scope
   48 |    sort(x,x+n);
      |         ^