제출 #360114

#제출 시각아이디문제언어결과실행 시간메모리
360114arnold518통행료 (IOI18_highway)C++14
12 / 100
268 ms262148 KiB
#include "highway.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 9e4; const int MAXM = 13e4; int N, M, S, T; ll A, B; pii E[MAXM+10]; vector<pii> adj[MAXN+10]; int TT[MAXM+10]; ll query() { vector<int> V; for(int i=0; i<M; i++) V.push_back(TT[i+1]); return ask(V); } int P[MAXN+10], dep[MAXN+10]; void dfs(int now, int bef, int d) { dep[now]=d; for(auto nxt : adj[now]) { if(nxt.first==bef) continue; P[nxt.first]=nxt.second; dfs(nxt.first, now, d+1); } } void find_pair(int _N, vector<int> _U, vector<int> _V, int _A, int _B) { N=_N; M=_U.size(); for(int i=1; i<=M; i++) E[i]={_U[i-1]+1, _V[i-1]+1}; for(int i=1; i<=M; i++) { adj[E[i].first].push_back({E[i].second, i}); adj[E[i].second].push_back({E[i].first, i}); } A=_A; B=_B; dfs(1, 1, 0); memset(TT, 0, sizeof(TT)); ll d=query()/A; vector<int> V; for(int i=1; i<=N; i++) { if(dep[i]==d) V.push_back(i); } int lo=0, hi=V.size(); while(lo+1<hi) { int mid=lo+hi>>1; for(int i=0; i<mid; i++) TT[P[V[i]]]=1; if(query()!=d*A) hi=mid; else lo=mid; for(int i=0; i<mid; i++) TT[P[V[i]]]=0; } T=V[lo]; S=1; answer(S-1, T-1); }

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

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:62:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   62 |   int mid=lo+hi>>1;
      |           ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...