Submission #61640

# Submission time Handle Problem Language Result Execution time Memory
61640 2018-07-26T08:39:58 Z huynhsmd Easter Eggs (info1cup17_eastereggs) C++17
0 / 100
10 ms 5524 KB
#include<bits/stdc++.h>
#include "grader.h"

#define pb push_back
#define fi first
#define se second
using namespace std;

typedef pair <int , int > ii;
const int N = 1e5 + 5;
int arr[N], cnt = 0;
vector < int > adj[N], ask;

void dfs(int u, int p){
	arr[++cnt] = u;
	for(int v : adj[u]) if(v != p) dfs(v, u);
}
int findEgg(int N, vector < ii > bridges){
	int n = N;
	for(int i = 1; i <= n; ++ i) adj[i].clear();
	for(ii i : bridges) adj[i.fi].pb(i.se), adj[i.se].pb(i.fi);
	dfs(1, 1);
	int l = 1, r = n, res;
	while(l <= r){
		int mid = l + r >> 1;
		for(int i = 1; i <= mid; ++ i) ask.pb(arr[i]);
		if(query(ask)) res = mid, r = mid - 1;
		else l = mid + 1;
	}
	return arr[res];
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:25:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int mid = l + r >> 1;
             ~~^~~
eastereggs.cpp:30:16: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
  return arr[res];
                ^
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 5172 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 10 ms 5404 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 10 ms 5524 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -