Submission #46267

# Submission time Handle Problem Language Result Execution time Memory
46267 2018-04-18T12:56:49 Z hiddentesla Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
3 ms 872 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;
vector<vector<int>> adj;
int findEgg (int n, vector < pair < int, int > > bridges)
{
    adj.resize(n+1);
    int temp,temp2;
    for(temp=0;temp<bridges.size();temp++)
    {
    	int x=bridges[temp].first,y=bridges[temp].second;
    	adj[x].push_back(y);
    	adj[y].push_back(x);
	}
	bool cntbisa[n+1]; int sisacnt=n;
	memset(cntbisa,true,sizeof(cntbisa));
	while(sisacnt>1)
	{
		queue<int> q;
		bool visited[n+1]; memset(visited,false,sizeof(visited));
		q.push(1);
		vector<int> stk;
		while(!q.empty())
		{
			int pos=q.front();
			q.pop();
			visited[pos]=true;
			if(cntbisa[pos])
			{
				stk.push_back(pos);	
			}
			if(stk.size()>sisacnt/2)
			{
				break;
			}
			for(temp=0;temp<adj[pos].size();temp++)
			{
				int thenode=adj[pos][temp];
				if(visited[thenode])	continue;
				q.push(thenode);
			}
		}
		int lol=query(stk);
		if(lol==1)
		{
			sisacnt=stk.size();
			memset(cntbisa,0,sizeof(cntbisa));
			for(temp=0;temp<stk.size();temp++)	cntbisa[stk[temp]]=true;
		}
		else
		{
			sisacnt-=stk.size();
			for(temp=0;temp<stk.size();temp++)	cntbisa[stk[temp]]=false;
		}	
	}
	for(temp=1;temp<=n;temp++)	if(cntbisa[temp])	return temp;
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:10:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(temp=0;temp<bridges.size();temp++)
                ~~~~^~~~~~~~~~~~~~~
eastereggs.cpp:33:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(stk.size()>sisacnt/2)
       ~~~~~~~~~~^~~~~~~~~~
eastereggs.cpp:37:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(temp=0;temp<adj[pos].size();temp++)
               ~~~~^~~~~~~~~~~~~~~~
eastereggs.cpp:49:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(temp=0;temp<stk.size();temp++) cntbisa[stk[temp]]=true;
               ~~~~^~~~~~~~~~~
eastereggs.cpp:54:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(temp=0;temp<stk.size();temp++) cntbisa[stk[temp]]=false;
               ~~~~^~~~~~~~~~~
eastereggs.cpp:9:14: warning: unused variable 'temp2' [-Wunused-variable]
     int temp,temp2;
              ^~~~~
eastereggs.cpp:58:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 424 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 2 ms 636 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 872 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -