답안 #446517

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
446517 2021-07-22T09:16:24 Z ritul_kr_singh Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
25 ms 360 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
 
vector<int> g[513];
int t[512], dfsTimer;
 
void dfs(int u, int p){
	t[dfsTimer++] = u;
	for(int v : g[u]) if(v != p) dfs(v, u);
}
 
int findEgg (int n, vector <pair<int, int>> e){
	for(int i=0; i<n; ++i) g[i+1].clear();
	dfsTimer = 0;
	
	for(auto &[u, v] : e){
		g[u].push_back(v);
		g[v].push_back(u);
	}
 
	dfs(1, 1);
 
	int x = 0;
	for(int y=n > 16 ? 512 : 16; y/=2; ){
		if(x + y <= n){
			vector<int> q(x+y);
			for(int j=0; j<x+y; ++j) q[j] = t[j];
			x += y * !query(q);
		}
	}
 
	return t[x];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 200 KB Number of queries: 4
2 Correct 1 ms 200 KB Number of queries: 4
3 Correct 1 ms 200 KB Number of queries: 4
4 Correct 1 ms 200 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 328 KB Number of queries: 9
2 Correct 13 ms 328 KB Number of queries: 9
3 Correct 25 ms 328 KB Number of queries: 9
4 Correct 19 ms 328 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 360 KB Number of queries: 9
2 Correct 20 ms 356 KB Number of queries: 9
3 Correct 21 ms 336 KB Number of queries: 9
4 Correct 19 ms 328 KB Number of queries: 9