답안 #821567

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
821567 2023-08-11T11:40:00 Z Dan4Life 통행료 (IOI18_highway) C++17
0 / 100
161 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];
int n, m, dist, dis[mxN];
vector<int> edges;

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 = m-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;
	}
	int x = l; l = 0, r = m-1;
	while(l<r){
		int mid = (l+r+1)/2; fill(all(w),0);
		fill(begin(w)+mid,end(w),1);
		if(ask(w)!=toll) l=mid;
		else r=mid-1;
	}
	answer(x,l+1);
}
# 결과 실행 시간 메모리 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 4 ms 4944 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 6228 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 5056 KB Output is incorrect: {s, t} is wrong.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 161 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 138 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -