Submission #61643

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
616432018-07-26 08:43:06huynhsmdEaster Eggs (info1cup17_eastereggs)C++17
100 / 100
46 ms3056 KiB
#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)) r = mid;
else l = mid + 1;
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

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:23:20: warning: unused variable 'res' [-Wunused-variable]
  int l = 1, r = n, res;
                    ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...