Submission #271981

# Submission time Handle Problem Language Result Execution time Memory
271981 2020-08-18T08:15:05 Z erkam Easter Eggs (info1cup17_eastereggs) C++17
0 / 100
3 ms 640 KB
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<utility>
#include<vector>
#include<stack>
#include<queue>
#include<cstring>
#include<set>
#include<map>
#include "grader.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define st first
#define nd second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long lo;
string s;

// int query(vector<int> hehe){

// }

int findEgg(int n,vector<pair<int,int> > bridges){
	vector<int>v[n+5];
	bool h[n+5]={0};
	for(lo i=0;i<n;i++){
		v[bridges[i].st].pb(bridges[i].nd);
		v[bridges[i].nd].pb(bridges[i].st);
	}
	int N=n;
	while(true){
		if(N==1){
			for(lo i=1;i<=n;i++){
				if(h[i]==0) return i;
			}
		}
		queue<int>q;
		map<int,bool>sorgu;
		q.push(1);
		int say=0;
		while(say<N/2){
			int x=q.front();
			q.pop();
			sorgu[x]=1;
			if(h[x]==0)say++;
			for(int i=0;i<v[x].size();i++){
				if(sorgu.count(v[x][i])==0)q.push(v[x][i]);
			}
		}
		vector<int>sor;
		for(int i=1;i<=n;i++){
			if(sorgu.count(i))sor.pb(i);
		}
		int x=query(sor);
		for(int i=1;i<=n;i++){
			if(sorgu.count(i)!=x)h[i]=1;
		}
		if(x==0) N-=say;
		else N=say;
	}
}
 
// int main(){

// }

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:50:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |    for(int i=0;i<v[x].size();i++){
      |                ~^~~~~~~~~~~~
eastereggs.cpp:60:21: warning: comparison of integer expressions of different signedness: 'std::map<int, bool>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   60 |    if(sorgu.count(i)!=x)h[i]=1;
      |       ~~~~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 384 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 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 -