Submission #61642

# Submission time Handle Problem Language Result Execution time Memory
61642 2018-07-26T08:41:21 Z huynhsmd Easter Eggs (info1cup17_eastereggs) C++17
87 / 100
49 ms 3084 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;
        ask.clear();
		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:31:16: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
  return arr[res];
                ^
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 2552 KB Number of queries: 5
2 Incorrect 5 ms 2640 KB Number of queries: 5
3 Incorrect 8 ms 2672 KB Number of queries: 5
4 Incorrect 7 ms 2852 KB Number of queries: 5
# Verdict Execution time Memory Grader output
1 Correct 11 ms 2964 KB Number of queries: 9
2 Correct 31 ms 2964 KB Number of queries: 9
3 Correct 49 ms 2964 KB Number of queries: 9
4 Correct 38 ms 3084 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 3084 KB Number of queries: 10
2 Correct 45 ms 3084 KB Number of queries: 9
3 Incorrect 42 ms 3084 KB Number of queries: 10
4 Incorrect 22 ms 3084 KB Number of queries: 10