답안 #102724

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
102724 2019-03-27T08:59:16 Z bert30702 통행료 (IOI18_highway) C++17
51 / 100
407 ms 63732 KB
#include <bits/stdc++.h>
#include "highway.h"
#define pii pair<int, int>
#define F first
#define S second
#define int long long
using namespace std;
const int MX = 1e6 + 100;
vector<pii> G1[MX], G2[MX];
bitset<MX> pass, edge;
int deep[MX];
//void answer(int a, int b) {
//	cout << "! " << a << ' ' << b;
//}
//int ask(vector<int32_t> v) {
//	for(auto it: v) cout << it << ' '; cout << endl;
//	int val; cin >> val; return val;
//}
vector<pii> que;
void dfs(int u, int l, int d) {
	que.push_back({u, l});
	deep[u] = d;
	for(auto it: G2[u]) {
		dfs(it.F, it.S, d + 1);
	}
}
void find_pair(int32_t n, vector<int32_t> u, vector<int32_t> v, int32_t a, int32_t b) {
	for(int i = 0; i < u.size(); i ++) {
		G1[u[i]].push_back({v[i], i});
		G1[v[i]].push_back({u[i], i});
	}
	int d = ask(vector<int32_t>(u.size(), 0));
	int l = 0, r = u.size() - 1;
	while(l != r) {
		int m = l + r >> 1;
		vector<int32_t> query(u.size(), 0);
		for(int j = l; j <= m; j ++) query[j] = 1;
		if(ask(query) > d) r = m;
		else               l = m + 1;
	}
	pass[u[l]] = pass[v[l]] = edge[l] = true;
	queue<int> q;
	q.push(u[l]);
	q.push(v[l]);
	while(q.size()) {
		int p = q.front(); q.pop();
		for(auto i: G1[p]) {
			if(!pass[i.F]) {
				edge[i.S] = true;
				pass[i.F] = true;
				G2[p].push_back(i);
				q.push(i.F);
			}
		}
	}
	vector<int> Yeeee = {u[l], v[l]}, YEEEE;
	for(auto it: Yeeee) {
		que.clear();
		dfs(it, l, 1);
		sort(que.begin(), que.end(), [](pii a, pii b) {
			return deep[a.F] < deep[b.F];	
		});
		int l = 0, r = que.size() - 1;
		while(l != r) {
			int m = l + r >> 1;
			vector<int32_t> query(u.size(), 1);
			for(int i = 0; i < u.size(); i ++) {
				if(edge[i]) query[i] = 0;
			}
			for(int i = m + 1; i <= r; i ++) {
				query[que[i].S] = 1;
			}
			if(ask(query) > d) l = m + 1;
			else               r = m;
		}
		YEEEE.push_back(que[l].F);
	}
	answer(YEEEE[0], YEEEE[1]);
}
//main () {
//	find_pair(4, {0, 0, 0, 1, 1, 2}, {1, 2, 3, 2, 3, 3}, 1, 2);
//}

Compilation message

highway.cpp: In function 'void find_pair(int32_t, std::vector<int>, std::vector<int>, int32_t, int32_t)':
highway.cpp:28:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < u.size(); i ++) {
                 ~~^~~~~~~~~~
highway.cpp:35:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int m = l + r >> 1;
           ~~^~~
highway.cpp:65:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    int m = l + r >> 1;
            ~~^~~
highway.cpp:67:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int i = 0; i < u.size(); i ++) {
                   ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 47224 KB Output is correct
2 Correct 45 ms 47228 KB Output is correct
3 Correct 54 ms 47224 KB Output is correct
4 Correct 46 ms 47272 KB Output is correct
5 Correct 44 ms 47272 KB Output is correct
6 Correct 43 ms 47316 KB Output is correct
7 Correct 44 ms 47212 KB Output is correct
8 Correct 44 ms 47352 KB Output is correct
9 Correct 45 ms 47260 KB Output is correct
10 Correct 44 ms 47300 KB Output is correct
11 Correct 46 ms 47304 KB Output is correct
12 Correct 45 ms 47272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 47480 KB Output is correct
2 Correct 66 ms 48632 KB Output is correct
3 Correct 261 ms 58884 KB Output is correct
4 Correct 276 ms 58944 KB Output is correct
5 Correct 284 ms 58980 KB Output is correct
6 Correct 265 ms 58936 KB Output is correct
7 Correct 268 ms 58868 KB Output is correct
8 Correct 288 ms 58968 KB Output is correct
9 Correct 266 ms 58956 KB Output is correct
10 Correct 278 ms 58872 KB Output is correct
11 Correct 260 ms 59284 KB Output is correct
12 Correct 318 ms 60920 KB Output is correct
13 Correct 289 ms 60704 KB Output is correct
14 Correct 247 ms 60660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 49280 KB Output is correct
2 Correct 86 ms 50672 KB Output is correct
3 Correct 95 ms 52512 KB Output is correct
4 Correct 213 ms 61356 KB Output is correct
5 Correct 226 ms 61348 KB Output is correct
6 Correct 236 ms 63208 KB Output is correct
7 Correct 199 ms 63732 KB Output is correct
8 Correct 242 ms 61944 KB Output is correct
9 Correct 218 ms 62900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 47368 KB Output is correct
2 Correct 69 ms 48424 KB Output is correct
3 Correct 215 ms 56500 KB Output is correct
4 Correct 246 ms 58940 KB Output is correct
5 Correct 264 ms 58888 KB Output is correct
6 Correct 264 ms 58932 KB Output is correct
7 Correct 255 ms 58936 KB Output is correct
8 Correct 250 ms 58932 KB Output is correct
9 Correct 245 ms 58952 KB Output is correct
10 Correct 267 ms 58960 KB Output is correct
11 Correct 307 ms 60416 KB Output is correct
12 Correct 303 ms 60756 KB Output is correct
13 Correct 291 ms 60796 KB Output is correct
14 Correct 292 ms 59660 KB Output is correct
15 Correct 267 ms 58872 KB Output is correct
16 Correct 248 ms 58948 KB Output is correct
17 Correct 296 ms 60520 KB Output is correct
18 Correct 266 ms 60924 KB Output is correct
19 Correct 258 ms 58888 KB Output is correct
20 Correct 268 ms 61000 KB Output is correct
21 Correct 232 ms 58796 KB Output is correct
22 Correct 224 ms 58812 KB Output is correct
23 Correct 259 ms 57016 KB Output is correct
24 Correct 240 ms 57408 KB Output is correct
25 Correct 302 ms 63268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 48584 KB Output is correct
2 Correct 64 ms 48792 KB Output is correct
3 Correct 307 ms 59660 KB Output is correct
4 Correct 338 ms 60140 KB Output is correct
5 Correct 407 ms 60364 KB Output is correct
6 Incorrect 378 ms 61348 KB Output is incorrect: {s, t} is wrong.
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 64 ms 48524 KB Output is correct
2 Correct 73 ms 48768 KB Output is correct
3 Correct 294 ms 58592 KB Output is correct
4 Incorrect 328 ms 59584 KB Output is incorrect: {s, t} is wrong.
5 Halted 0 ms 0 KB -