제출 #173710

#제출 시각아이디문제언어결과실행 시간메모리
173710maximath_1철로 (IOI14_rail)C++11
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; vector<pair<int, int> >v; set<int>C, D; void findLocation(int n, int first, int l[], int t[]){ l[0]=first; t[0]=1; //block 0, C station for(int i=1; i<n; i++) v.push_back({getDistance(0, i), i}); sort(v.begin(), v.end()); l[v[0].second]=first+v[0].first; t[v[0].second]=2; //the first D station C.insert(l[0]); D.insert(l[v[0].second]); int L=0, R=v[0].second; for(int i=1; i<v.size(); i++){ int idx=v[i].second; int lf=getDistance(idx, L); int rg=getDistance(idx, R); int lfcan=l[L]+lf, rgcan=l[R]-rg; bool isC; auto it1=--C.upper_bound(lfcan); if(rg==lfcan-*it1+l[R]-*it1){ isC=false; }else{ auto it2=D.upper_bound(rgcan); if(it2!=D.end() && lf==*it2-rgcan+*it2-l[L]){ isC=true; }else{ if(v[i].first==2*l[v[0].second]-l[0]-rgcan) isC=true; else isC=false; } } if(isC){ l[idx]=rgcan; t[idx]=1; C.insert(l[idx]); if(l[L]>l[idx]) L=idx; }else{ l[idx]=lfcan; t[idx]=2; D.insert(l[idx]); if(l[R]>l[idx]) R=idx; } } }

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

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:8:16: error: 'getDistance' was not declared in this scope
   v.push_back({getDistance(0, i), i});
                ^~~~~~~~~~~
rail.cpp:8:16: note: suggested alternative: 'getline'
   v.push_back({getDistance(0, i), i});
                ^~~~~~~~~~~
                getline
rail.cpp:8:37: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
   v.push_back({getDistance(0, i), i});
                                     ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from rail.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:939:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]
       push_back(const value_type& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:939:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const std::pair<int, int>&}'
/usr/include/c++/7/bits/stl_vector.h:953:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]
       push_back(value_type&& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:953:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >::value_type&& {aka std::pair<int, int>&&}'
rail.cpp:15:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=1; i<v.size(); i++){
               ~^~~~~~~~~
rail.cpp:17:10: error: 'getDistance' was not declared in this scope
   int lf=getDistance(idx, L);
          ^~~~~~~~~~~
rail.cpp:17:10: note: suggested alternative: 'getline'
   int lf=getDistance(idx, L);
          ^~~~~~~~~~~
          getline