제출 #334080

#제출 시각아이디문제언어결과실행 시간메모리
334080nicholask통행료 (IOI18_highway)C++14
컴파일 에러
0 ms0 KiB
#include "highway.h" #include <bits/stdc++.h> #define x first #define y second using namespace std; vector <pair <int,int> > g[90000]; //first: connection to which node, second: edge no. long long dist; vector <pair <int,int> > poss; void dfs(int cur,int prev,int d){ for (auto&i:g[cur]){ if (i.x==prev) continue; if (d+1==dist) poss.push_back({i.y,i.x}); else dfs(i.x,cur,d+1); } } void find_pair(int n,vector <int> u,vector <int> v,long long a,int b){ int m=u.size(); for (int i=0; i<m; i++){ g[u[i]].push_back({v[i],i}); g[v[i]].push_back({u[i],i}); } vector <int> query(m,0); dist=ask(query); dist/=a; bool can=1; for (int i=0; i<m; i++){ if (u[i]!=i||v[i]!=i+1){ can=0; break; } } if (can){ //subtask 3 vector <int> possible; for (int i=0; i<n; i++) possible.push_back(i); while (possible.size()>1){ vector <int> f,s; for (int i=0; i<possible.size(); i++){ if (i<(possible.size()/2)) f.push_back(possible[i]); else s.push_back(possible[i]); } vector <int> query(m,0); for (auto&i:f) query[i]=1; if (ask(query)==dist*a) possible=s; else possible=f; } answer(possible[0],possible[0]+dist); } else { dfs(0,-1,0); while (poss.size()>1){ vector <pair <int,int> > f,s; for (int i=0; i<poss.size(); i++){ if (i<(poss.size()/2)) f.push_back(poss[i]); else s.push_back(poss[i]); } vector <int> query(m,0); for (auto&i:f) query[i.x]=1; if (ask(query)==dist*a) poss=s; else poss=f; } answer(0,poss[0].y); } }

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

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, long long int, int)':
highway.cpp:37:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |    for (int i=0; i<possible.size(); i++){
      |                  ~^~~~~~~~~~~~~~~~
highway.cpp:38:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     if (i<(possible.size()/2)) f.push_back(possible[i]);
      |         ~^~~~~~~~~~~~~~~~~~~~
highway.cpp:51:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |    for (int i=0; i<poss.size(); i++){
      |                  ~^~~~~~~~~~~~
highway.cpp:52:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     if (i<(poss.size()/2)) f.push_back(poss[i]);
      |         ~^~~~~~~~~~~~~~~~
/tmp/cc0OGvIT.o: In function `main':
grader.cpp:(.text.startup+0x129): undefined reference to `find_pair(int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, int, int)'
collect2: error: ld returned 1 exit status