답안 #439489

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
439489 2021-06-30T06:00:07 Z Yazan_Alattar Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
25 ms 448 KB
#include <iostream>
#include <fstream>
#include <cstring>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <algorithm>


#include "grader.h"

using namespace std;

#define endl "\n"
#define F first
#define S second
#define pb push_back
typedef long long ll;
const int M = 550;
const int mod = 1e9+7;

vector <int> adj[M], ord;

void dfs(int node, int p)
{
    ord.pb(node);
    for(auto i : adj[node]){
        if(i == p) continue;
        dfs(i, node);
    }
    return;
}

int findEgg(int N, vector<pair<int, int>> bridges) {
	for (int i = 1; i <= N; i++) adj[i].clear();
	ord.clear();
	for (pair<int, int> i : bridges) {
		adj[i.first].push_back(i.second);
		adj[i.second].push_back(i.first);
	}
	dfs(1, 0);
	int l = 0, r = N - 1;
	while (l != r) {
		int mid = (l + r + 1) / 2;
		if (query(vector<int>(ord.begin(), ord.begin() + mid))) r = mid - 1;
		else l = mid;
	}
	return ord[l];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Number of queries: 4
2 Correct 2 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: 8
2 Correct 15 ms 340 KB Number of queries: 9
3 Correct 22 ms 340 KB Number of queries: 9
4 Correct 19 ms 340 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 348 KB Number of queries: 9
2 Correct 22 ms 344 KB Number of queries: 9
3 Correct 25 ms 448 KB Number of queries: 9
4 Correct 17 ms 336 KB Number of queries: 9