제출 #1134163

#제출 시각아이디문제언어결과실행 시간메모리
1134163Ak_16철로 (IOI14_rail)C++20
컴파일 에러
0 ms0 KiB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int dis1[10000];
int sp;
int dis2[10000];
int sta[10000];
int mnd;


struct pla{
  int x, y;
};

vector<pla> lef;
vector<pla> rig;

bool cmp1(const pla &a, const pla&b){
  return a.y > b.y;
}

bool cmp2(const pla &a, const pla&b){
  return a.y < b.y;
}

int getDistance(int i, int j);


void findLocation(int n, int first, int loc[], int stype[]){
  loc[0] = first;
  stype[0]=1;
  sp = 0;
  sta[0] = 2;
  mnd = 100000000;
  
  
  for(int i=1; i<n; i++){
    dis1[i] = getDistance(0, i);
    if(dis1[i]<mnd){sp = i; mnd = dis1[i];}
  }
  
  loc[sp] = first + dis1[sp];
  stype[sp]=2;
  sta[sp] = 2;
  
  
  
  mnd = 100000000;
  
  for(int i=1; i<n; i++){
    if(i!=sp){
      
      dis2[i] = getDistance(sp, i);
      
      if(dis1[i] == dis2[i] + dis1[sp]){
        if(dis2[i]<dis1[sp]){sta[i] = 2; loc[i] = loc[sp] - dis2[i]; stype[i] = 1;}
        else {sta[i] = 1;}
      }
      else {sta[i] = 3;}
      
    }
  }
  
  
  for(int i=1; i<n; i++){
    if(sta[i]==1){
      lef.push_back(i, dis2[i]);
    }
    if(sta[i]==3){
      rig.push_back(i, dis1[i]);
    }
  }
  
  sort(rig.begin(), rig.end(), cmp2);
  sort(lef.begin(), lef.end(), cmp2);
  int cur = sp;
  
  for(const &auto inf : rig){
    int n1 = inf.x;
    int n2 = inf.y;
    
    if(cur==sp){
      loc[n1] = first + n2;
      stype[n1] = 2;
      cur = n1;
    }
    
    else {
      
      int n3 = getDistance(cur, n1);
      
      if(n2 == n3 + dis1[cur]){
        
        loc[n1] = loc[cur] - n3;
        stype[n1] = 1;
        
      }
      
      else {
        
        loc[n1] = first + n2;
        stype[n1] = 2;
        cur = n1;
        
      }
      
    }
  }
  
  cur = 0;
  
  for(const &auto inf : lef){
    int n1 = inf.x;
    int n2 = inf.y;
    
    if(cur==0){
      loc[n1] = loc[sp] - n2;
      stype[n1] = 1;
      cur = n1;
    }
    
    else {
      
      int n3 = getDistance(cur, n1);
      
      if(n2 == n3 + dis1[cur]){
        
        loc[n1] = loc[cur] + n3;
        stype[n1] = 2;
        
      }
      
      else {
        
        loc[n1] = loc[sp] - n2;
        stype[n1] = 1;
        cur = n1;
        
      }
      
    }
  }
  
}

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

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:69:20: error: no matching function for call to 'std::vector<pla>::push_back(int&, int&)'
   69 |       lef.push_back(i, dis2[i]);
      |       ~~~~~~~~~~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/vector:67,
                 from rail.cpp:2:
/usr/include/c++/11/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = pla; _Alloc = std::allocator<pla>; std::vector<_Tp, _Alloc>::value_type = pla]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1187:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/11/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = pla; _Alloc = std::allocator<pla>; std::vector<_Tp, _Alloc>::value_type = pla]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1203:7: note:   candidate expects 1 argument, 2 provided
rail.cpp:72:20: error: no matching function for call to 'std::vector<pla>::push_back(int&, int&)'
   72 |       rig.push_back(i, dis1[i]);
      |       ~~~~~~~~~~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/vector:67,
                 from rail.cpp:2:
/usr/include/c++/11/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = pla; _Alloc = std::allocator<pla>; std::vector<_Tp, _Alloc>::value_type = pla]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1187:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/11/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = pla; _Alloc = std::allocator<pla>; std::vector<_Tp, _Alloc>::value_type = pla]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1203:7: note:   candidate expects 1 argument, 2 provided
rail.cpp:80:14: error: expected unqualified-id before 'auto'
   80 |   for(const &auto inf : rig){
      |              ^~~~
rail.cpp:80:14: error: expected ';' before 'auto'
   80 |   for(const &auto inf : rig){
      |              ^~~~
      |              ;
rail.cpp:80:23: error: found ':' in nested-name-specifier, expected '::'
   80 |   for(const &auto inf : rig){
      |                       ^
      |                       ::
rail.cpp:80:19: error: 'inf' has not been declared
   80 |   for(const &auto inf : rig){
      |                   ^~~
rail.cpp:80:28: error: qualified-id in declaration before ')' token
   80 |   for(const &auto inf : rig){
      |                            ^
rail.cpp:80:28: error: expected ';' before ')' token
   80 |   for(const &auto inf : rig){
      |                            ^
      |                            ;
rail.cpp:81:14: error: 'inf' was not declared in this scope; did you mean 'int'?
   81 |     int n1 = inf.x;
      |              ^~~
      |              int
rail.cpp:114:14: error: expected unqualified-id before 'auto'
  114 |   for(const &auto inf : lef){
      |              ^~~~
rail.cpp:114:14: error: expected ';' before 'auto'
  114 |   for(const &auto inf : lef){
      |              ^~~~
      |              ;
rail.cpp:114:23: error: found ':' in nested-name-specifier, expected '::'
  114 |   for(const &auto inf : lef){
      |                       ^
      |                       ::
rail.cpp:114:19: error: 'inf' has not been declared
  114 |   for(const &auto inf : lef){
      |                   ^~~
rail.cpp:114:28: error: qualified-id in declaration before ')' token
  114 |   for(const &auto inf : lef){
      |                            ^
rail.cpp:114:28: error: expected ';' before ')' token
  114 |   for(const &auto inf : lef){
      |                            ^
      |                            ;
rail.cpp:115:14: error: 'inf' was not declared in this scope; did you mean 'int'?
  115 |     int n1 = inf.x;
      |              ^~~
      |              int