답안 #97632

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
97632 2019-02-17T14:50:11 Z KLPP Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
4 ms 512 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;
typedef pair<int,int> pii;
vector<int> nei[1000];
int findEgg (int N, vector < pair < int, int > > bridges)
{
	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);
	}
	pii dist[n];
	for(int i=0;i<n;i++)dist[i].first=-1,dist[i].second=i;
	queue<int> q;
	q.push(0);
	dist[0].first=0;
	while(!q.empty()){
		int u=q.front();q.pop();
		for(int i=0;i<nei[u].size();i++){
			int v=nei[u][i];
			if(dist[v].first==-1){
				dist[v].first=dist[u].first+1;
				q.push(v);
			}
		}
	}
	sort(dist,dist+n);
	//for(int i=0;i<n;i++)cout<<dist[i].second<<endl;
	int lo=-1;
	int hi=n-1;
	while(hi-lo>1){
		int mid=(hi+lo)/2;
		vector<int> v;
		for(int i=0;i<=mid;i++)v.push_back(dist[i].second+1);
		if(query(v)){
			hi=mid;
		}else lo=mid;
	}
	return hi+1;
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:11:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<bridges.size();i++){
              ~^~~~~~~~~~~~~~~
eastereggs.cpp:22:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<nei[u].size();i++){
               ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 476 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 484 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -