답안 #243080

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
243080 2020-06-30T09:14:40 Z hollwo_pelw Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
21 ms 2688 KB
#include<bits/stdc++.h>
#include "grader.h"
using namespace std;
// type
//#define int long long
typedef long long ll;
typedef long double ld;
// loop
//#define For(i, l, r, x)     for (int i = l; i < r; i+=x)
//#define ForE(i, l, r, x)    for (int i = l; i <= r; i+=x)
//#define Ford(i, r, l)       for (int i = r; i > l; i--)
//#define FordE(i, r, l)      for (int i = r; i >= l; i--)
//#define Fora(i, a)          for (auto i : a)
// I/O 
#define openfile(file)      freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
#define testinput(file)     freopen(file".txt", "r", stdin); 
#define FAST_IO             std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
//#define PrintV(a)           Fora(ii, a) cout << ii << ' '; cout << rl;
//#define PrintVl(a)          Fora(ii, a) cout << ii << rl;
//#define PrintA(a, l, r)     for (int ii = l; ii <= r; ii++) cout << a[ii] << ' '; cout << rl;
//#define PrintAl(a, l, r)    for (int ii = l; ii <= r; ii++) cout << a[ii] << rl;
//#define Ptest(x)            return cout << x, 0;
#define setpre(n)           fixed << setprecision(n)
// pair
#define F                   first
#define S                   second
#define pii                 pair<int, int>
#define pll                 pair<ll, ll>
#define pdd                 pair<ld, ld>
// vector & !!?(string)
#define eb                  emplace_back
#define pb                  push_back
#define all(a)              a.begin(), a.end()
#define rall(a)             a.rbegin(), a.rend()
#define sz(a)               a.size()
#define len(a)              a.length()
// geometry calc    
#define pi                  acos(-1.0)
#define g_sin(a)            sin(a*pi/180)
#define g_cos(a)            cos(a*pi/180)
#define g_tan(a)            tan(a*pi/180)
// set val
#define ms0(a)              memset(a,        0, sizeof(a));
#define ms1(a)              memset(a,        1, sizeof(a));
#define msn1(a)             memset(a,       -1, sizeof(a));
#define msinf(a)            memset(a, 0x3f3f3f, sizeof(a));
// constant
const int mod1 = 998244353, mod = 1e9+7;
const int MAXN = 1000005, MAXM = 200010;
// code
vector<int> g[100000], vis;
 
void dfs(int u, int f = -1) {
	vis.pb(u);
	for(int i: g[u])
		if(i != f)
			dfs(i, u);
}
 
int findEgg(int N, vector< pair<int, int> > bridges) {
	vis.clear();
    for(int i = 1; i <= N; i++){
        g[i].clear();
    }
	for(auto i: bridges) {
		g[i.F].pb(i.S);
		g[i.S].pb(i.F);
	}
	dfs(1);
  	int l = 1, r = N;
  	while(l < r) {
		int m = (l + r) >> 1;
		if(query(vector<int>(vis.begin(), vis.begin() + m)))
            r = m;
        else
            l = m + 1;
	}
	return vis[l-1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2688 KB Number of queries: 4
2 Correct 7 ms 2688 KB Number of queries: 4
3 Correct 6 ms 2688 KB Number of queries: 4
4 Correct 7 ms 2688 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 2688 KB Number of queries: 8
2 Correct 16 ms 2688 KB Number of queries: 9
3 Correct 21 ms 2688 KB Number of queries: 9
4 Correct 21 ms 2688 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 2688 KB Number of queries: 9
2 Correct 19 ms 2688 KB Number of queries: 9
3 Correct 20 ms 2688 KB Number of queries: 9
4 Correct 19 ms 2688 KB Number of queries: 9