Submission #1249121

#TimeUsernameProblemLanguageResultExecution timeMemory
1249121redacodeDancing Elephants (IOI11_elephants)C++20
Compilation error
0 ms0 KiB
#include "elephants.h" #include "bits/stdc++.h" using namespace std; int n; int l; bool cmp(pair<int, int>& a, pair<int, 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++; if(i==n-1) cnt++ } } return cnt; }

Compilation message (stderr)

elephants.cpp: In function 'int update(int, int)':
elephants.cpp:48:28: error: expected ';' before '}' token
   48 |            if(i==n-1) cnt++
      |                            ^
      |                            ;
   49 |        }
      |        ~