Submission #648430

# Submission time Handle Problem Language Result Execution time Memory
648430 2022-10-06T12:28:25 Z ymm Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
20 ms 372 KB
#include <bits/stdc++.h>
#include "grader.h"
#define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;

const int N = 513;
vector<int> A[N];
int ord[N];

void dfs(int v, int p, int &t)
{
	ord[t++] = v;
	for (int u : A[v])
		if (u != p)
			dfs(u, v, t);
}

int qry(int r)
{
	vector<int> q;
	Loop (i,0,r)
		q.push_back(ord[i]);
	return query(q);
}

int findEgg(int N, vector<pair<int, int>> bridges)
{
	Loop (i,1,N+1)
		A[i].clear();
	Loop (i,0,N-1) {
		auto [v, u] = bridges[i];
		A[v].push_back(u);
		A[u].push_back(v);
	}
	dfs(1, -1, *new int(0));
	int l = 0, r = N-1;
	while (l < r) {
		int mid = (l+r)/2;
		if (qry(mid+1))
			r = mid;
		else
			l = mid+1;
	}
	return ord[l];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Number of queries: 4
2 Correct 1 ms 208 KB Number of queries: 4
3 Correct 1 ms 208 KB Number of queries: 4
4 Correct 1 ms 208 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 6 ms 372 KB Number of queries: 8
2 Correct 11 ms 352 KB Number of queries: 9
3 Correct 20 ms 348 KB Number of queries: 9
4 Correct 15 ms 356 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 16 ms 356 KB Number of queries: 9
2 Correct 16 ms 364 KB Number of queries: 9
3 Correct 17 ms 344 KB Number of queries: 9
4 Correct 14 ms 364 KB Number of queries: 9