Submission #115951

# Submission time Handle Problem Language Result Execution time Memory
115951 2019-06-10T03:25:55 Z nhimnam120 Easter Eggs (info1cup17_eastereggs) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;
vector<long long> ask;
vector<long long> adj[1001];
bool used[1001],wrong[1001];
long long size=0;
long long cnt;
void dfs(long long node, long long par){
	if(cnt==size/2) return;
	if(used[node]==0) cnt++;
	ask.push_back(node);
	for(auto i : adj[node]){
		if(wrong[i]!=0||i==par) continue;
		dfs(i,node);
	}
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
    ask.clear();
	for(int i=0;i<=1000;i++){
		adj[i].clear;
	}
	memset(used,0,sizeof(used));
	memset(wrong,0,sizeof(wrong));
	size=N;
	for(auto i: bridges){
		long long left=i.first;
		long long right=i.second;
		adj[left].push_back(right);
		adj[right].push_back(left);
	}
	while(true){
		ask.clear();
		if(size==1){
			for(int i=1;i<=N;i++){
				if(used[i]==0&&wrong==0){
					return i;
				}
			}
		}
		else{
			cnt=0;
			dfs(1,1);
			if(query(ask)==1){
				size=cnt;
				bool vs[1001];
				memset(vs,0,sizeof(vs));
				for(auto i:ask){
					vs[i]=1;
				}
				for(int i=1;i<=N;i++){
					if(vs[i]==0){
						wrong[i]=true;
					}
				}
			}
			else{
				size=size-cnt;
				for(auto i:ask){
					used[i]=true;
				}
			}
		}
	}
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:23:10: error: invalid use of non-static member function 'void std::vector<_Tp, _Alloc>::clear() [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
   adj[i].clear;
   ~~~~~~~^~~~~
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from eastereggs.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:1247:7: note: declared here
       clear() _GLIBCXX_NOEXCEPT
       ^~~~~
eastereggs.cpp:46:16: error: could not convert 'ask' from 'std::vector<long long int>' to 'std::vector<int>'
    if(query(ask)==1){
                ^