Submission #522139

# Submission time Handle Problem Language Result Execution time Memory
522139 2022-02-03T23:57:02 Z maks007 Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
19 ms 368 KB
#include <bits/stdc++.h>
#include "grader.h"
 
using namespace std;
 
int findEgg (int N, vector < pair < int, int > > bridges)
{
	vector <int> sub;
	vector <int> g[N];
	function <void(int, int)> dfs=[&](int v, int p) {
		sub.push_back(v);
		for(auto u : g[v]) {
			if(u !=  p) dfs(u, v);
		}
	};
	for(int i = 0; i < bridges.size(); i ++) {
		g[bridges[i].first - 1].push_back(bridges[i].second - 1);
		g[bridges[i].second - 1].push_back(bridges[i].first - 1);
	}
	dfs(0, -1);
	int l = 0, r = sub.size() - 1;
	while(l < r) {
		int m = (l +r) >> 1;
		vector < int> q;
		for(int i = 0; i <= m; i ++) q.push_back(sub[i]+1);
		if(query(q)) {
			r = m;
		}else l = m + 1;
	}
	return sub[l]+1;
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:16:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |  for(int i = 0; i < bridges.size(); i ++) {
      |                 ~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Number of queries: 4
2 Correct 1 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
# Verdict Execution time Memory Grader output
1 Correct 5 ms 340 KB Number of queries: 8
2 Correct 11 ms 328 KB Number of queries: 9
3 Correct 15 ms 332 KB Number of queries: 9
4 Correct 15 ms 336 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 17 ms 368 KB Number of queries: 9
2 Correct 15 ms 340 KB Number of queries: 9
3 Correct 19 ms 332 KB Number of queries: 9
4 Correct 16 ms 348 KB Number of queries: 9