Submission #480529

# Submission time Handle Problem Language Result Execution time Memory
480529 2021-10-16T19:32:33 Z Haidara Easter Eggs (info1cup17_eastereggs) C++17
0 / 100
227 ms 131076 KB
#include<bits/stdc++.h>
#include<grader.h>
#define ff first 
#define ss second
#define rep(i,x,n) for(int i=x;i<n;i++)
#define FOR(i,n) rep(i,0,n)
using namespace std;
const int maxn=200200;
vector<int>graph[maxn],ord;
void dfs(int st=1,int par=-1)
{
	ord.push_back(st);
    for(auto i:graph[st])
    {
    	if(i==par)
    		continue;
    	dfs(i,st);
    }
}
int findEgg(int n,vector< pair<int,int> >edges)
{
    for(auto i:edges)
    {
        graph[i.ff].push_back(i.ss);
        graph[i.ss].push_back(i.ff);
    }
    dfs();    
    int l=0,r=n-1,ans;
    while(l<=r)
    {
    	int mid=l+(r-l)/2;
    	if(query(vector<int>(ord.begin(),ord.begin()+mid)))
    		r=mid-1,ans=ord[mid];
    	else 
    		l=mid+1;
    }
    return ans;
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:37:12: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   37 |     return ans;
      |            ^~~
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 9996 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 227 ms 131076 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 226 ms 131076 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -