제출 #1249115

#제출 시각아이디문제언어결과실행 시간메모리
1249115redacode코끼리 (Dancing Elephants) (IOI11_elephants)C++20
컴파일 에러
0 ms0 KiB
#include "elephants.h"

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++;
       }
   }
   return cnt;
}

컴파일 시 표준 에러 (stderr) 메시지

elephants.cpp:5:10: error: 'pair' was not declared in this scope
    5 | bool cmp(pair<int, int>& a,
      |          ^~~~
elephants.cpp:5:15: error: expected primary-expression before 'int'
    5 | bool cmp(pair<int, int>& a,
      |               ^~~
elephants.cpp:5:20: error: expected primary-expression before 'int'
    5 | bool cmp(pair<int, int>& a,
      |                    ^~~
elephants.cpp:6:9: error: 'pair' was not declared in this scope
    6 |         pair<int, int>& b)
      |         ^~~~
elephants.cpp:6:14: error: expected primary-expression before 'int'
    6 |         pair<int, int>& b)
      |              ^~~
elephants.cpp:6:19: error: expected primary-expression before 'int'
    6 |         pair<int, int>& b)
      |                   ^~~
elephants.cpp:6:26: error: expression list treated as compound expression in initializer [-fpermissive]
    6 |         pair<int, 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;
      |                ^