답안 #1058156

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1058156 2024-08-14T08:45:42 Z ReLice 통행료 (IOI18_highway) C++17
69 / 100
144 ms 28520 KB
#include "highway.h"
#include <bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define pb push_back
#define pf push_front
#define sz size()
#define bc back()
#define pob pop_back()
#define pof pop_front()
#define fr first
#define sc second
using namespace std;
const ll N=2e5+7;
const ll inf=1e18;
vector<vector<array<ll,2>>> g(N), g2(N);
void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
	ll M = V.sz;
	ll s, t, rt;
	ll n = N;
	vll v, u;
	ll i;
	
	for(auto i : V) v.pb(i);
	for(auto i : U) u.pb(i);
	
	vector<int> w(M, 0);
	
	ll x = ask(w);
	
	for(i=0;i<M;i++){
		g[v[i]].pb({u[i], i});
		g[u[i]].pb({v[i], i});
	}
	
	{//getting vertex on the path
		ll l = 0, r = n;
		while(l + 1 < r){
			ll m = (l + r) / 2;
			
			if(r - l > 60000) m = 60000;
			
			w.assign(M, 0);
			
			for(i=n-1;i>=m-1;i--){
				for(auto [to, r] : g[i]) w[r] = 1;
			}
			
			ll y = ask(w);
			
			if(y == x) r = m;
			else l = m;
		}
		
		rt = l - 1;
	}
	
	vll p(n), d(n);
	vll pr(n), tour;
	vector<vll> dd(n);
	
	auto bfs = [&](ll s){
		for(i=0;i<n;i++){
			dd[i].clear();
			d[i] = inf;
			pr[i] = p[i] = -1;
		}
		
		queue<ll> q;
		q.push(s);
		d[s] = 0;
		
		while(q.size()){
			ll x = q.front();
			q.pop();
			
			dd[d[x]].pb(x);
			
			for(auto [to, r] : g[x]){
				if(d[to] > d[x] + 1){
					d[to] = d[x] + 1 ;
					pr[to] = r;
					p[to] = x;
					q.push(to);
				}
			}
		}
		
		tour.clear();
		for(i=0;i<n;i++){
			for(auto j : dd[i]) tour.pb(j);
		}
	};
	
	vll path;
	auto calc = [&](ll N){
		ll l = 0, r = N;
		while(l + 1 < r){
			ll m = (l + r) / 2;
			
			if(r - l > 60000) m = 30000;
			
			w.assign(M, 1);
			
			for(auto i : path) w[i] =0;
			
			//~ cout<<m<<endl;
			for(i=1;i<m;i++) {
				w[pr[tour[i]]] = 0;
				//~ cout<<v[pr[tour[i]]]<<' '<<u[pr[tour[i]]]<<endl;
			}
			
			ll y = ask(w);
				
			if(x == y) r = m;
			else l = m;
		}
		
		return r - 1;
	};
	
	bfs(rt);
	
	ll k = calc(n);
	s = tour[k];
	
	{
		ll x = s;
		while(x != rt){
			path.pb(pr[x]);
			x = p[x];
		}
	}
	
	t = tour[calc(k - 1)];
	
	answer(s, t);
}


# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 9816 KB Output is correct
2 Correct 2 ms 9816 KB Output is correct
3 Correct 2 ms 9816 KB Output is correct
4 Correct 3 ms 9724 KB Output is correct
5 Correct 3 ms 9816 KB Output is correct
6 Correct 3 ms 9704 KB Output is correct
7 Correct 2 ms 9816 KB Output is correct
8 Correct 2 ms 9816 KB Output is correct
9 Correct 2 ms 9840 KB Output is correct
10 Correct 3 ms 9816 KB Output is correct
11 Correct 3 ms 9816 KB Output is correct
12 Correct 2 ms 9816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 9816 KB Output is correct
2 Correct 10 ms 11700 KB Output is correct
3 Correct 82 ms 24240 KB Output is correct
4 Correct 95 ms 24260 KB Output is correct
5 Correct 93 ms 24204 KB Output is correct
6 Correct 84 ms 24052 KB Output is correct
7 Correct 74 ms 24132 KB Output is correct
8 Correct 84 ms 24088 KB Output is correct
9 Correct 75 ms 24132 KB Output is correct
10 Correct 80 ms 24108 KB Output is correct
11 Correct 85 ms 24652 KB Output is correct
12 Correct 119 ms 24540 KB Output is correct
13 Correct 82 ms 24296 KB Output is correct
14 Correct 93 ms 24280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 11608 KB Output is correct
2 Correct 18 ms 13112 KB Output is correct
3 Correct 22 ms 14932 KB Output is correct
4 Correct 63 ms 24664 KB Output is correct
5 Correct 61 ms 24892 KB Output is correct
6 Correct 68 ms 25496 KB Output is correct
7 Correct 64 ms 25600 KB Output is correct
8 Correct 61 ms 24756 KB Output is correct
9 Correct 73 ms 25024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 9928 KB Output is correct
2 Correct 9 ms 11492 KB Output is correct
3 Correct 60 ms 21272 KB Output is correct
4 Correct 83 ms 24024 KB Output is correct
5 Correct 79 ms 24160 KB Output is correct
6 Correct 66 ms 24152 KB Output is correct
7 Correct 70 ms 24128 KB Output is correct
8 Correct 79 ms 23988 KB Output is correct
9 Correct 90 ms 24220 KB Output is correct
10 Correct 86 ms 24244 KB Output is correct
11 Correct 107 ms 24496 KB Output is correct
12 Correct 92 ms 24516 KB Output is correct
13 Correct 102 ms 24444 KB Output is correct
14 Correct 96 ms 24328 KB Output is correct
15 Correct 82 ms 24088 KB Output is correct
16 Correct 73 ms 24096 KB Output is correct
17 Correct 98 ms 24516 KB Output is correct
18 Correct 92 ms 24316 KB Output is correct
19 Correct 81 ms 24144 KB Output is correct
20 Correct 88 ms 24684 KB Output is correct
21 Correct 76 ms 24656 KB Output is correct
22 Correct 76 ms 24948 KB Output is correct
23 Correct 79 ms 24544 KB Output is correct
24 Correct 85 ms 24592 KB Output is correct
25 Correct 89 ms 25876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 11352 KB Output is correct
2 Correct 11 ms 11608 KB Output is correct
3 Correct 109 ms 25176 KB Output is correct
4 Correct 125 ms 26324 KB Output is correct
5 Correct 120 ms 28216 KB Output is correct
6 Correct 121 ms 28520 KB Output is correct
7 Correct 120 ms 28140 KB Output is correct
8 Correct 122 ms 28500 KB Output is correct
9 Correct 102 ms 21952 KB Output is correct
10 Correct 87 ms 22804 KB Output is correct
11 Correct 106 ms 24408 KB Output is correct
12 Correct 110 ms 26872 KB Output is correct
13 Correct 139 ms 27860 KB Output is correct
14 Correct 120 ms 28100 KB Output is correct
15 Correct 116 ms 28288 KB Output is correct
16 Correct 109 ms 24292 KB Output is correct
17 Correct 88 ms 24080 KB Output is correct
18 Correct 86 ms 24864 KB Output is correct
19 Correct 77 ms 24384 KB Output is correct
20 Correct 84 ms 24552 KB Output is correct
21 Correct 123 ms 27896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 11560 KB Output is correct
2 Correct 14 ms 11684 KB Output is correct
3 Correct 95 ms 25216 KB Output is correct
4 Correct 109 ms 25856 KB Output is correct
5 Correct 109 ms 26352 KB Output is correct
6 Correct 144 ms 28216 KB Output is correct
7 Correct 97 ms 25092 KB Output is correct
8 Correct 100 ms 25576 KB Output is correct
9 Correct 103 ms 26376 KB Output is correct
10 Correct 114 ms 28060 KB Output is correct
11 Correct 108 ms 28084 KB Output is correct
12 Correct 130 ms 28128 KB Output is correct
13 Correct 110 ms 24260 KB Output is correct
14 Correct 103 ms 22664 KB Output is correct
15 Correct 112 ms 24232 KB Output is correct
16 Correct 95 ms 22856 KB Output is correct
17 Correct 113 ms 24208 KB Output is correct
18 Correct 90 ms 22716 KB Output is correct
19 Correct 123 ms 27088 KB Output is correct
20 Correct 120 ms 27540 KB Output is correct
21 Correct 132 ms 28136 KB Output is correct
22 Correct 129 ms 28108 KB Output is correct
23 Correct 122 ms 28100 KB Output is correct
24 Correct 124 ms 28160 KB Output is correct
25 Correct 116 ms 28300 KB Output is correct
26 Correct 125 ms 28392 KB Output is correct
27 Correct 83 ms 24440 KB Output is correct
28 Correct 75 ms 24452 KB Output is correct
29 Correct 80 ms 24876 KB Output is correct
30 Correct 71 ms 24428 KB Output is correct
31 Correct 82 ms 24504 KB Output is correct
32 Correct 104 ms 24292 KB Output is correct
33 Partially correct 91 ms 25052 KB Output is partially correct
34 Correct 85 ms 24964 KB Output is correct
35 Correct 72 ms 24652 KB Output is correct
36 Correct 75 ms 24228 KB Output is correct
37 Correct 77 ms 24784 KB Output is correct
38 Correct 84 ms 24640 KB Output is correct
39 Correct 109 ms 27848 KB Output is correct
40 Incorrect 137 ms 28076 KB Output is incorrect: {s, t} is wrong.
41 Halted 0 ms 0 KB -