Submission #361991

# Submission time Handle Problem Language Result Execution time Memory
361991 2021-02-01T14:08:34 Z keta_tsimakuridze Easter Eggs (info1cup17_eastereggs) C++14
87 / 100
24 ms 440 KB
#include <bits/stdc++.h>
#include "grader.h"
#define f first
#define s second
using namespace std;
const int N=525;
int sz[N],par[N],fix[N],n,Egg[N],cnt,ind[N],timer,ans;
vector<int>v,V[N];
void dfs(int u,int p){
	timer++;
	ind[timer]=u;  
	for(int i=0;i<V[u].size();i++){
		if(V[u][i]==p) continue;
		dfs(V[u][i],u);
	}
}
int findEgg (int n1, vector < pair < int, int > > b)
{
	n=n1; timer=0;
  for(int i=1;i<=n;i++)V[i].clear();
   for(int i=0;i<b.size();i++){
   	V[b[i].f].push_back(b[i].s);
   	V[b[i].s].push_back(b[i].f);
   }
   dfs(1,0);
   int l=1,r=n;	
   while(l<=r){
   	int mid=(l+r)/2;
   	v.clear();
   	for(int i=1;i<=mid;i++){
   		v.push_back(ind[i]);
	}
	if(query(v)){
		ans=ind[mid];
		r=mid-1;
	}
	else l=mid+1;
   }
   return ans;
}

Compilation message

eastereggs.cpp: In function 'void dfs(int, int)':
eastereggs.cpp:12:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  for(int i=0;i<V[u].size();i++){
      |              ~^~~~~~~~~~~~
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:21:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |    for(int i=0;i<b.size();i++){
      |                ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 364 KB Number of queries: 5
2 Partially correct 1 ms 364 KB Number of queries: 5
3 Partially correct 1 ms 364 KB Number of queries: 5
4 Partially correct 1 ms 364 KB Number of queries: 5
# Verdict Execution time Memory Grader output
1 Correct 6 ms 364 KB Number of queries: 9
2 Correct 15 ms 364 KB Number of queries: 9
3 Correct 23 ms 440 KB Number of queries: 9
4 Correct 19 ms 364 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Partially correct 24 ms 364 KB Number of queries: 10
2 Correct 16 ms 364 KB Number of queries: 9
3 Partially correct 20 ms 364 KB Number of queries: 10
4 Partially correct 20 ms 364 KB Number of queries: 10