제출 #438941

#제출 시각아이디문제언어결과실행 시간메모리
438941leinad2통행료 (IOI18_highway)C++17
컴파일 에러
0 ms0 KiB
//#include "highway.h" #include<bits/stdc++.h> using namespace std; vector<pair<int, int> >adj[90010]; int vis[90010]; void find_pair(int N, vector<int>U, vector<int>V, int A, int B) { int M=U.size(); vector<int>w(M);long long X=ask(w); for(int i=0;i<M;i++) { adj[U[i]].push_back({V[i], i}); adj[V[i]].push_back({U[i], i}); } int s=0;int e=M-1; while(s<e) { int m=s+e>>1; for(int i=0;i<M;i++)w[i]=0; for(int i=0;i<=m;i++)w[i]=1; if(ask(w)>X)e=m; else s=m+1; } int S=U[s], E=V[s]; queue<pair<int, int> >q; q.push({S, 0}); q.push({E, 1}); vis[S]=vis[E]=1; vector<pair<int, int> >v1, v2; while(q.size()) { int a=q.front().first;int b=q.front().second;q.pop(); for(int i=0;i<adj[a].size();i++) { int p=adj[a][i].first; if(vis[p])continue; vis[p]=1;q.push({p, b}); if(b==0)v1.push_back(adj[a][i]); else v2.push_back(adj[a][i]); } } int ans1; if(v1.size()) { int a=0;int b=v1.size()-1; while(a<b) { int m=a+b+1>>1; for(int i=0;i<M;i++)w[i]=0; for(int i=m;i<=b;i++)w[v1[i].second]=1; if(ask(w)>X)a=m; else b=m-1; } ans1=v1[a].first; } else ans1=S; int ans2; if(v2.size()) { int a=0;int b=v2.size()-1; while(a<b) { int m=a+b+1>>1; for(int i=0;i<M;i++)w[i]=0; for(int i=m;i<=b;i++)w[v2[i].second]=1; if(ask(w)>X)a=m; else b=m-1; } ans2=v2[a].first; } else ans2=E; answer(ans1, ans2); }

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

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:9:33: error: 'ask' was not declared in this scope
    9 |     vector<int>w(M);long long X=ask(w);
      |                                 ^~~
highway.cpp:18:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   18 |         int m=s+e>>1;
      |               ~^~
highway.cpp:33:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for(int i=0;i<adj[a].size();i++)
      |                     ~^~~~~~~~~~~~~~
highway.cpp:48:22: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   48 |             int m=a+b+1>>1;
      |                   ~~~^~
highway.cpp:63:22: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   63 |             int m=a+b+1>>1;
      |                   ~~~^~
highway.cpp:72:5: error: 'answer' was not declared in this scope
   72 |     answer(ans1, ans2);
      |     ^~~~~~