Submission #337031

#TimeUsernameProblemLanguageResultExecution timeMemory
337031blueGondola (IOI14_gondola)C++11
Compilation error
0 ms0 KiB
#include "gondola.h" #include <iostream> #include <set> #include <vector> using namespace std; int valid(int n, int inputSeq[]) { set<int> S; int prev = -1, prev_pos = -1; for(int i = 0; i < n; i++) { if(S.find(inputSeq[i]) != S.end()) return 0; S.insert(inputSeq[i]); if(inputSeq[i] > n) continue; if(prev != -1) { if((i - prev_pos + n) % n != (inputSeq[i] - prev + n) % n) return 0; } prev = inputSeq[i]; prev_pos = i; } return 1; } int* gondolaSeqGlobal; int replacement(int n, int gondolaSeq[], int replacementSeq[]) { gondolaSeqGlobal = gondolaSeq; vector<int> I(n); for(int i = 0; i < n; i++) I[i] = i; sort(I.begin(), I.end(), [] (int x, int y) { return gondolaSeqGlobal[x] < gondolaSeqGlobal[y]; }); int pos1 = 0; for(int i = 0; i < n; i++) { if(gondolaSeq[i] <= n) { pos1 = (i + 1 - gondolaSeq[i] + n) % n; break; } } int l = 0; if(gondolaSeq[ I[0] ] > n) { replacementSeq[l] = ((I[0] - pos1 + n) % n) + 1; l++; } for(int j = n+1; j < gondolaSeq[ I[0] ]; j++) { replacementSeq[l] = j; l++; } for(int i = 1; i < n; i++) { if(gondolaSeq[ I[i] ] > n) { replacementSeq[l] = ((I[i] - pos1 + n) % n) + 1; l++; } for(int j = max(n+1, gondolaSeq[ I[i-1] ] + 1); j < gondolaSeq[ I[i] ]; j++) { replacementSeq[l] = j; l++; } } return l; }

Compilation message (stderr)

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:33:5: error: 'sort' was not declared in this scope; did you mean 'qsort'?
   33 |     sort(I.begin(), I.end(), [] (int x, int y)
      |     ^~~~
      |     qsort