답안 #821523

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
821523 2023-08-11T11:05:41 Z Dan4Life 통행료 (IOI18_highway) C++17
0 / 100
171 ms 262144 KB
#include "highway.h"
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
const int mxN = (int)2e5+10;
using ll = long long;
vector<pair<int,int>> adj[mxN];
vector<int> edges;
int n,m,dist = 0, dis[mxN];
void dfs(int s, int p){
	if(p!=-1) dis[s] = dis[p]+1;
	else dis[s] = 0;
	for(auto [u,i] : adj[s]){	
		if(u!=p){
			dfs(u,s);
			if(dis[u]==dist) edges.pb(i);
		}
	}
}

void find_pair(int N, vi u, vi v, int A, int B) {
	n = N; m = sz(u); vi w(m,0);
	for(int i = 0; i < m; i++){
		int a = u[i], b = v[i];
		adj[a].pb({b,i}); adj[b].pb({a,i});
	}
	ll toll = ask(w);
	dist = toll/A; dfs(0,-1);
	int l = 0, r = sz(edges)-1;
	while(l<r){
		int mid = (l+r)/2;
		fill(all(w),0);
		for(int i = 0; i <= mid; i++) w[edges[i]]=1;
		if(ask(w)!=toll) r=mid;
		else l=mid+1;
	}
	answer(0,dis[u[l]]<dis[v[l]]?v[l]:u[l]);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4944 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4944 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 6280 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4944 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 171 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 140 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -