제출 #422780

#제출 시각아이디문제언어결과실행 시간메모리
422780alireza_kaviani통행료 (IOI18_highway)C++11
5 / 100
279 ms15452 KiB
#include "highway.h" #include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; const int MAXN = 2e5 + 10; int n , timer , st[MAXN] , prv[MAXN]; vector<pii> adj[MAXN]; vector<int> get(int x){ vector<int> ans(n - 1 , 0); for(int i = 0 ; i < n ; i++){ if(st[i] >= x) ans[prv[i]] = 1; } return ans; } void DFS(int v , int p = -1){ st[v] = ++timer; for(pii i : adj[v]){ int u = i.first , w = i.second; if(u == p) continue; prv[u] = w; DFS(u , v); } } int solve(int root){ fill(st , st + MAXN , 0); fill(prv , prv + MAXN , -1); timer = 0 , DFS(root); int l = 0 , r = n , dist = ask(get(n)); while(r - l > 1){ int mid = l + r >> 1; if(ask(get(mid)) > dist) l = mid; else r = mid; } for(int i = 0 ; i < n ; i++) if(st[i] == l) return i; } void find_pair(int N, vector<int> U, vector<int> V, int A, int B) { if(U.size() != N - 1) return; n = N; for(int i = 0 ; i < n - 1 ; i++){ adj[V[i]].push_back({U[i] , i}); adj[U[i]].push_back({V[i] , i}); } int s = solve(0) , t = solve(s); answer(s , t); }

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

highway.cpp: In function 'int solve(int)':
highway.cpp:35:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   35 |   int mid = l + r >> 1;
      |             ~~^~~
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:43:14: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   43 |  if(U.size() != N - 1) return; n = N;
      |     ~~~~~~~~~^~~~~~~~
highway.cpp:43:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   43 |  if(U.size() != N - 1) return; n = N;
      |  ^~
highway.cpp:43:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   43 |  if(U.size() != N - 1) return; n = N;
      |                                ^
highway.cpp: In function 'int solve(int)':
highway.cpp:40:1: warning: control reaches end of non-void function [-Wreturn-type]
   40 | }
      | ^
#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...