답안 #98327

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
98327 2019-02-22T12:06:34 Z tmk Easter Eggs (info1cup17_eastereggs) C++17
0 / 100
8 ms 548 KB
#include<bits/stdc++.h>
#include "grader.h"
using namespace std;
#ifndef d
#define d(...)
#endif
#define st first
#define nd second
#define pb push_back
#define siz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
typedef long long LL;
typedef long double LD;
constexpr int INF=1e9+7;
constexpr LL INFL=1e18;
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

constexpr int maxn = 520;

int n;
vector<int> G[maxn];
bool vis[maxn];

vector<int> get_bfs_order() {
	vector<int> ret;
	ret.push_back(1);
	vis[1] = true;
	for(int i=0; i<siz(ret); i++) {
		auto w = ret[i];
		for(auto v:G[w])
			if(not vis[v]) {
				vis[v] = true;
				ret.push_back(v);
			}
	}
	
	return ret;
}

int findEgg(int _n, vector<pair<int, int>> edges) {
	n = _n;
	for(int i=1; i<=n; i++)
		G[i].clear(), vis[i] = false;
	for(auto& e:edges) {
		G[e.st].push_back(e.nd);
		G[e.nd].push_back(e.st);
	}
	
	auto&& v = get_bfs_order();
	int l = 0, r = n-1;
	while(l < r) {
		auto s = (l+r) / 2;
		if(query(vector<int>(v.begin(), v.begin() + s)))
			r = s;
		else
			l = s;
	}
	
	return v[l];
}
	
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 548 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 484 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -