Submission #1249155

#TimeUsernameProblemLanguageResultExecution timeMemory
1249155redacodeDancing 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; } set<pair<int, int> > A; /* void sort_map(map<int, int>& M) { A.clear(); 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]; A.insert({i,X[i]}); } } int update(int i, int y) { if(n==1){ return 1; } A.erase({i,pos[i]}); pos[i]=y; A.insert({i,pos[i]}); //sort_map(pos); int cnt =0; int start = *A.begin(); for(auto&: it){ if(it.second-start>l){ start = it.second; cnt++; } if(i==n-1) cnt++; } if(cnt==0)cnt++; return cnt; }

Compilation message (stderr)

elephants.cpp: In function 'int update(int, int)':
elephants.cpp:49:16: error: cannot convert 'const std::pair<int, int>' to 'int' in initialization
   49 |    int start = *A.begin();
      |                ^~~~~~~~~~
      |                |
      |                const std::pair<int, int>
elephants.cpp:50:13: error: expected unqualified-id before ':' token
   50 |    for(auto&: it){
      |             ^
elephants.cpp:50:15: error: 'it' was not declared in this scope; did you mean 'i'?
   50 |    for(auto&: it){
      |               ^~
      |               i