Submission #1032060

#TimeUsernameProblemLanguageResultExecution timeMemory
1032060tolbiGondola (IOI14_gondola)C++17
Compilation error
0 ms0 KiB
#include "gondola.h" int valid(int n, int inputSeq[]) { map<int,int> mp; int p = -1; for (int i = 0; i < n; ++i) { if (mp[inputSeq[i]]) return 0; mp[inputSeq[i]]++; } for (int i = 0; i < n; i++){ if (inputseQ[i]<=n){ p=i; break; } } if (p==-1) return 1; for (int i = 0; i < n; i++){ if (inputseQ[i]>n) continue; int step = i-p; if (i<p) step = n-p+i; int a = inputSeq[p]-1; a+=step; a%=n; a++; if (inputseQ[i]!=a) return 0; } return 1; } //---------------------- int replacement(int n, int gondolaSeq[], int replacementSeq[]) { pair<int,int> v[n]; for (int i = 0; i < n; ++i) { v[i]={gondolaSeq[i],i}; } sort(v,v+n); int cnt = 0; for (int i = 0; i < v.size(); i++){ if (v[i].first<=n) continue; while (cnt<v[i].first-n) replacement[cnt++]=v[i].second; } return cnt; } //---------------------- int countReplacement(int n, int inputSeq[]) { return -3; }

Compilation message (stderr)

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:5:2: error: 'map' was not declared in this scope
    5 |  map<int,int> mp;
      |  ^~~
gondola.cpp:5:6: error: expected primary-expression before 'int'
    5 |  map<int,int> mp;
      |      ^~~
gondola.cpp:9:7: error: 'mp' was not declared in this scope; did you mean 'p'?
    9 |   if (mp[inputSeq[i]]) return 0;
      |       ^~
      |       p
gondola.cpp:10:3: error: 'mp' was not declared in this scope; did you mean 'p'?
   10 |   mp[inputSeq[i]]++;
      |   ^~
      |   p
gondola.cpp:13:7: error: 'inputseQ' was not declared in this scope; did you mean 'inputSeq'?
   13 |   if (inputseQ[i]<=n){
      |       ^~~~~~~~
      |       inputSeq
gondola.cpp:20:7: error: 'inputseQ' was not declared in this scope; did you mean 'inputSeq'?
   20 |   if (inputseQ[i]>n) continue;
      |       ^~~~~~~~
      |       inputSeq
gondola.cpp:27:7: error: 'inputseQ' was not declared in this scope; did you mean 'inputSeq'?
   27 |   if (inputseQ[i]!=a) return 0;
      |       ^~~~~~~~
      |       inputSeq
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:36:2: error: 'pair' was not declared in this scope
   36 |  pair<int,int> v[n];
      |  ^~~~
gondola.cpp:36:7: error: expected primary-expression before 'int'
   36 |  pair<int,int> v[n];
      |       ^~~
gondola.cpp:39:3: error: 'v' was not declared in this scope
   39 |   v[i]={gondolaSeq[i],i};
      |   ^
gondola.cpp:41:7: error: 'v' was not declared in this scope
   41 |  sort(v,v+n);
      |       ^
gondola.cpp:41:2: error: 'sort' was not declared in this scope; did you mean 'short'?
   41 |  sort(v,v+n);
      |  ^~~~
      |  short
gondola.cpp:45:45: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   45 |   while (cnt<v[i].first-n) replacement[cnt++]=v[i].second;
      |                                             ^