답안 #61603

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
61603 2018-07-26T08:00:09 Z IOrtroiii Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
38 ms 3084 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
 
const int N = 1e5 + 5;
 
int n;
vector<int> G[N], ask;
int arr[N], tot = 0;
 
void dfs(int u,int p) {
	arr[++tot] = u;
	for (int v : G[u]) if (v != p) {
		dfs(v, u);
	} 
}
 
int findEgg(int n,vector<pair<int,int>> bridges) {
	for (int i = 1; i <= n; ++i) G[i].clear();
	
	for (auto ed : bridges) {
		int u = ed.first, v = ed.second;
		G[u].push_back(v), G[v].push_back(u);
	}
	
	dfs(1, 1);
	int l = 1, r = n;
	while (l < r) {
		int mid = l + r >> 1;
		ask.clear();
		for (int i = 1; i <= mid; ++i) ask.push_back(arr[i]);
		if (query(ask)) r = mid; else l = mid + 1;
	}
	return arr[l];
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:29:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int mid = l + r >> 1;
             ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2656 KB Number of queries: 4
2 Correct 6 ms 2828 KB Number of queries: 4
3 Correct 6 ms 2828 KB Number of queries: 4
4 Correct 5 ms 2828 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 2840 KB Number of queries: 8
2 Correct 25 ms 2904 KB Number of queries: 9
3 Correct 24 ms 2904 KB Number of queries: 9
4 Correct 36 ms 3056 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 3056 KB Number of queries: 9
2 Correct 20 ms 3056 KB Number of queries: 9
3 Correct 35 ms 3084 KB Number of queries: 9
4 Correct 35 ms 3084 KB Number of queries: 9