Submission #765725

# Submission time Handle Problem Language Result Execution time Memory
765725 2023-06-25T04:08:52 Z khshg Highway Tolls (IOI18_highway) C++14
12 / 100
200 ms 262144 KB
#include "highway.h"
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using str = string;
 
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<ld, ld>;
#define mp make_pair
#define ff first
#define ss second
 
#define ar array
template<class T> using V = vector<T>;
using vi = V<int>;
using vb = V<bool>;
using vl = V<ll>;
using vd = V<ld>;
using vs = V<str>;
using vpi = V<pi>;
using vpl = V<pl>;
using vpd = V<pd>;
 
#define sz(x) (int)((x).size())
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define pb push_back
#define eb emplace_back
#define ft front()
#define bk back()
#define lb lower_bound
#define ub upper_bound
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for(int i = (b) - 1; i >= (a); --i)
#define R0F(i, a) ROF(i, 0, a)
#define rep(a) F0R(_, a)
#define trav(a, x) for(auto& a : x)
 
template<class T> bool ckmin(T& a, const T& b) { return (b < a ? a = b, 1 : 0); }
template<class T> bool ckmax(T& a, const T& b) { return (b > a ? a = b, 1 : 0); }

int N, M;
ll A, B;
V<vpi> adj;
vi dep, par;

void root(int S) {
	dep[S] = 0;
	trav(u, adj[S]) {
		if(u.ff == par[S]) continue;
		par[u.ff] = S;
		root(u.ff);
		ckmax(dep[S], dep[u.ff] + 1);
	}
}

void find_pair(int _N, vi x, vi y, int _A, int _B) {
	swap(N, _N);
	A = _A;
	B = _B;
	M = sz(x);
	adj.rsz(N);
	F0R(i, N) adj[i].clear();
	F0R(i, M) {
		adj[x[i]].eb(y[i], i);
		adj[y[i]].eb(x[i], i);
	}

	int dis = (int)(ask(vi(M, 0)) / A);
	int S;
	{// find starting node ideally in 30 calls
		S = 0;
	}
	par.rsz(N); dep.rsz(N);
	par[S] = -1;
	root(S);
	int cur = S;
	F0R(i, dis) {
		assert(dep[cur] >= dis - i);
		vi oke;
		trav(u, adj[cur]) {
			if(u.ff == par[cur]) continue;
			if(dep[u.ff] >= dis - i - 1) oke.eb(u.ss);
		}
		int L = 0, R = sz(oke) - 1;
		while(L < R) {
			int MID = (L + R) / 2;
			vi ASK(M);
			FOR(j, L, MID + 1) ASK[oke[j]] = 1;
			if(ask(ASK) == A * dis) {
				L = MID + 1;
			} else {
				R = MID;
			}
		}
		cur = x[oke[L]] + y[oke[R]] - cur;
	}
	answer(S, cur);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 0 ms 208 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 7 ms 1104 KB Output is correct
3 Correct 80 ms 8244 KB Output is correct
4 Correct 65 ms 8244 KB Output is correct
5 Correct 79 ms 8184 KB Output is correct
6 Correct 64 ms 8168 KB Output is correct
7 Correct 118 ms 8188 KB Output is correct
8 Correct 107 ms 8168 KB Output is correct
9 Correct 99 ms 8248 KB Output is correct
10 Correct 64 ms 8124 KB Output is correct
11 Correct 76 ms 8700 KB Output is correct
12 Correct 104 ms 9064 KB Output is correct
13 Correct 97 ms 8708 KB Output is correct
14 Correct 63 ms 8392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 1488 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 200 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 196 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -