답안 #243057

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
243057 2020-06-30T08:24:58 Z Xenocryptix Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
25 ms 640 KB
#include<bits/stdc++.h>
#include "grader.h"
using namespace std;

#define fi first
#define se second
#define pb push_back
vector<int> g[10000], q;

void dfs(int u, int f = -1) {
	q.pb(u);
	for(int i: g[u])
		if(i != f)
			dfs(i, u);
}

int bin_search(int l, int r) {
	while(l < r) {
		int m = (l + r) >> 1;
		if(query(vector<int>(q.begin(), q.begin() + m)))
            r = m;
        else
            l = m + 1;
	}
	return l;
}

int findEgg(int N, vector< pair<int, int> > bridges) {
	q.clear();
    for(int i = 1; i <= N; i++){
        g[i].clear();
    }
	for(auto i: bridges) {
		g[i.fi].pb(i.se);
		g[i.se].pb(i.fi);
	}
	dfs(1);
	return q[bin_search(1, N) - 1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Number of queries: 4
2 Correct 6 ms 512 KB Number of queries: 4
3 Correct 5 ms 512 KB Number of queries: 4
4 Correct 5 ms 512 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 512 KB Number of queries: 8
2 Correct 18 ms 512 KB Number of queries: 9
3 Correct 25 ms 640 KB Number of queries: 9
4 Correct 23 ms 640 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 640 KB Number of queries: 9
2 Correct 20 ms 512 KB Number of queries: 9
3 Correct 25 ms 512 KB Number of queries: 9
4 Correct 23 ms 640 KB Number of queries: 9