Submission #1249114

#TimeUsernameProblemLanguageResultExecution timeMemory
1249114redacodeDancing Elephants (IOI11_elephants)C++20
Compilation error
0 ms0 KiB
#include "elephants.h" int n; int l; bool cmp(pair<string, int>& a, pair<string, int>& b) { return a.second < b.second; } vector<pair<int, int> > A; void sort_map(map<int, int>& M) { for (auto& it : M) { A.push_back(it); } sort(A.begin(), A.end(), cmp); } map<int,int> pos; void init(int N, int L, int X[]) { n = N; l =L; for(int i=0;i<n;i++){ pos[i]=X[i]; } } int update(int i, int y) { pos[i]=y; sort_map(pos); int cnt =0; int start = A[0].second; for(int i=1;i<n;i++){ if(A[i].second-start>l){ start = A[i].second; cnt++; } } return cnt; }

Compilation message (stderr)

elephants.cpp:5:15: error: 'string' was not declared in this scope
    5 | bool cmp(pair<string, int>& a,
      |               ^~~~~~
elephants.cpp:5:15: error: 'string' was not declared in this scope
elephants.cpp:5:15: error: 'string' was not declared in this scope
elephants.cpp:5:15: error: 'string' was not declared in this scope
elephants.cpp:5:15: error: 'string' was not declared in this scope
elephants.cpp:5:15: error: 'string' was not declared in this scope
elephants.cpp:5:15: error: 'string' was not declared in this scope
elephants.cpp:5:15: error: 'string' was not declared in this scope
elephants.cpp:5:15: error: 'string' was not declared in this scope
elephants.cpp:5:10: error: 'pair' was not declared in this scope
    5 | bool cmp(pair<string, int>& a,
      |          ^~~~
elephants.cpp:5:15: error: 'string' was not declared in this scope
    5 | bool cmp(pair<string, int>& a,
      |               ^~~~~~
elephants.cpp:5:23: error: expected primary-expression before 'int'
    5 | bool cmp(pair<string, int>& a,
      |                       ^~~
elephants.cpp:6:14: error: 'string' was not declared in this scope
    6 |         pair<string, int>& b)
      |              ^~~~~~
elephants.cpp:6:14: error: 'string' was not declared in this scope
elephants.cpp:6:14: error: 'string' was not declared in this scope
elephants.cpp:6:14: error: 'string' was not declared in this scope
elephants.cpp:6:14: error: 'string' was not declared in this scope
elephants.cpp:6:9: error: 'pair' was not declared in this scope
    6 |         pair<string, int>& b)
      |         ^~~~
elephants.cpp:6:14: error: 'string' was not declared in this scope
    6 |         pair<string, int>& b)
      |              ^~~~~~
elephants.cpp:6:22: error: expected primary-expression before 'int'
    6 |         pair<string, int>& b)
      |                      ^~~
elephants.cpp:6:29: error: expression list treated as compound expression in initializer [-fpermissive]
    6 |         pair<string, int>& b)
      |                             ^
elephants.cpp:11:8: error: 'pair' was not declared in this scope
   11 | vector<pair<int, int> > A;
      |        ^~~~
elephants.cpp:11:8: error: 'pair' was not declared in this scope
elephants.cpp:11:8: error: 'pair' was not declared in this scope
elephants.cpp:11:8: error: 'pair' was not declared in this scope
elephants.cpp:11:8: error: 'pair' was not declared in this scope
elephants.cpp:11:8: error: 'pair' was not declared in this scope
elephants.cpp:11:8: error: 'pair' was not declared in this scope
elephants.cpp:11:8: error: 'pair' was not declared in this scope
elephants.cpp:11:8: error: 'pair' was not declared in this scope
elephants.cpp:11:1: error: 'vector' does not name a type
   11 | vector<pair<int, int> > A;
      | ^~~~~~
elephants.cpp:13:6: error: variable or field 'sort_map' declared void
   13 | void sort_map(map<int, int>& M)
      |      ^~~~~~~~
elephants.cpp:13:15: error: 'map' was not declared in this scope
   13 | void sort_map(map<int, int>& M)
      |               ^~~
elephants.cpp:13:19: error: expected primary-expression before 'int'
   13 | void sort_map(map<int, int>& M)
      |                   ^~~
elephants.cpp:13:24: error: expected primary-expression before 'int'
   13 | void sort_map(map<int, int>& M)
      |                        ^~~
elephants.cpp:24:1: error: 'map' does not name a type
   24 | map<int,int> pos;
      | ^~~
elephants.cpp: In function 'void init(int, int, int*)':
elephants.cpp:31:7: error: 'pos' was not declared in this scope
   31 |       pos[i]=X[i];
      |       ^~~
elephants.cpp: In function 'int update(int, int)':
elephants.cpp:39:4: error: 'pos' was not declared in this scope
   39 |    pos[i]=y;
      |    ^~~
elephants.cpp:40:4: error: 'sort_map' was not declared in this scope
   40 |    sort_map(pos);
      |    ^~~~~~~~
elephants.cpp:42:16: error: 'A' was not declared in this scope
   42 |    int start = A[0].second;
      |                ^