제출 #78910

#제출 시각아이디문제언어결과실행 시간메모리
78910wleung_bvg통행료 (IOI18_highway)C++14
51 / 100
398 ms8992 KiB
#include "highway.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define eb emplace_back #define mp make_pair #define f first #define s second #define all(a) (a).begin(),(a).end() #define For(i,a,b) for(auto i=(a);i<(b);i++) #define FOR(i,b) For(i,0,b) #define Rev(i,a,b) for(auto i=(a);i>(b);i--) #define REV(i,a) Rev(i,a,-1) #define FORE(i,a) for(auto&&i:a) #define sz(a) (int((a).size())) #define MIN(a,b) ((a)=min((a),(b))) #define MAX(a,b) ((a)=max((a),(b))) using ll=long long;using ld=long double;using uint=unsigned int;using ull=unsigned long long; using pii=pair<int,int>;using pll=pair<ll,ll>;using pill=pair<int,ll>;using plli=pair<ll,int>;using pdd=pair<double,double>;using pld=pair<ld,ld>; constexpr const char nl='\n',sp=' ';constexpr const int INT_INF=0x3f3f3f3f;constexpr const ll LL_INF=0x3f3f3f3f3f3f3f3f; constexpr const double D_INF=numeric_limits<double>::infinity();constexpr const ld LD_INF=numeric_limits<ld>::infinity();constexpr const double EPS=1e-9; const int MAXN = 90005, MAXM = 130005; int q[MAXN], to[MAXN]; bool good[MAXM]; vector<int> adj[MAXN]; void find_pair(int N, vector<int> U, vector<int> V, int A, int B) { int M = sz(U), front, back, s = 0, lo = 0, hi = M - 1, mid, v; FOR(i, M) { adj[U[i]].pb(i); adj[V[i]].pb(i); } vector<int> Q(M, 0); ll DA = ask(Q); while (lo < hi) { mid = lo + (hi - lo) / 2; FOR(i, M) Q[i] = i <= mid; if (ask(Q) == DA) lo = mid + 1; else hi = mid; } s = U[lo]; vector<int> ans; fill(good, good + M, 1); FOR(_, 2) { front = 0, back = 0, lo = 1, hi = N - 1; fill(to, to + N, -1); to[q[back++] = s] = -INT_INF; while (front < back) FORE(e, adj[v = q[front++]]) if (good[e] && to[v ^ U[e] ^ V[e]] == -1) good[to[q[back++] = v ^ U[e] ^ V[e]] = e] = 0; while (lo <= hi) { mid = lo + (hi - lo) / 2; fill(all(Q), 0); For(i, mid, N) Q[to[q[i]]] = 1; if (ask(Q) == DA) hi = mid - 1; else lo = mid + 1; } FOR(i, M) good[i] ^= 1; ans.pb(s = q[hi]); } answer(ans[0], ans[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...