Submission #97702

# Submission time Handle Problem Language Result Execution time Memory
97702 2019-02-17T18:17:39 Z KLPP Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
4 ms 652 KB
#include <bits/stdc++.h>
#include "grader.h"
 
using namespace std;
typedef pair<int,int> pii;
vector<int> nei[1000];
vector<int> order;

void DFS(int u,int last){
	order.push_back(u);
	for(int i=0;i<nei[u].size();i++){
		int v=nei[u][i];
		if(v!=last){
			DFS(v,u);
		}
	}
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
	order.clear();
	int n=N;
	for(int i=0;i<n;i++)nei[i].clear();
	for(int i=0;i<bridges.size();i++){
		nei[bridges[i].first-1].push_back(bridges[i].second-1);
		nei[bridges[i].second-1].push_back(bridges[i].first-1);
	}
	DFS(0,-1);
	/*for(int i=0;i<n;i++){
		vector<int> v;
		v.push_back(i+1);
		if(query(v))return i+1;
	}*/
	//for(int i=0;i<n;i++)cout<<dist[i].second<<endl;
	int lo=0;
	int hi=n;
	while(hi-lo>1){
		int mid=(hi+lo)/2;
		vector<int> v;
		for(int i=0;i<mid;i++)v.push_back(order[i]+1);
		if(query(v)){
			hi=mid;
		}else lo=mid;
	}
	/*for(int i=0;i<n;i++){
		vector<int> v;
		v.push_back(i+1);
		if(query(v))return i+1;
	}*/
	return lo+1;
}

Compilation message

eastereggs.cpp: In function 'void DFS(int, int)':
eastereggs.cpp:11:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<nei[u].size();i++){
              ~^~~~~~~~~~~~~~
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:23:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<bridges.size();i++){
              ~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 512 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 3 ms 640 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 4 ms 652 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -