답안 #821472

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
821472 2023-08-11T10:38:25 Z Dan4Life 통행료 (IOI18_highway) C++17
0 / 100
9 ms 5660 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=-1){
	if(p!=-1) dis[s] = dis[p]+1;
	else dis[s] = 0;
	for(auto [u,i] : adj[s]){	
		if(u!=p){
			if(dis[s]==dist-1) edges.pb(i);
			dfs(u,s);
		}
	}
}

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;
	int l = 0, r = sz(edges)-1;
	while(l<r){
		int mid = (l+r)/2;
		fill(all(w),0);
		fill(begin(w),begin(w)+mid,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 3 ms 4944 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 5460 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 8 ms 5660 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 5504 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -