답안 #62235

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
62235 2018-07-27T23:05:11 Z Benq Easter Eggs (info1cup17_eastereggs) C++11
100 / 100
42 ms 588 KB
#include "grader.h"

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

vi vv, adj[513];

void dfs(int x, int y) {
	vv.pb(x);
	for (int i: adj[x]) if (i != y) dfs(i,x);
}

// int query (vector < int > h);

int findEgg (int N, vector < pair < int, int > > bridges) {
	vv.clear();
	FOR(i,1,N+1) adj[i].clear();
	for (auto a: bridges) adj[a.f].pb(a.s), adj[a.s].pb(a.f);
	dfs(1,0);
	int lo = 1, hi = N;
	while (lo < hi) {
		int mid = (lo+hi)/2;
		if (query(vi(vv.begin(),vv.begin()+mid))) hi = mid;
		else lo = mid+1;
	}
	return vv[lo-1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Number of queries: 4
2 Correct 3 ms 308 KB Number of queries: 4
3 Correct 4 ms 384 KB Number of queries: 4
4 Correct 3 ms 588 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 588 KB Number of queries: 8
2 Correct 18 ms 588 KB Number of queries: 9
3 Correct 42 ms 588 KB Number of queries: 9
4 Correct 27 ms 588 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 588 KB Number of queries: 9
2 Correct 13 ms 588 KB Number of queries: 9
3 Correct 33 ms 588 KB Number of queries: 9
4 Correct 37 ms 588 KB Number of queries: 9