Submission #332561

# Submission time Handle Problem Language Result Execution time Memory
332561 2020-12-02T21:40:16 Z codemaster111 Easter Eggs (info1cup17_eastereggs) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;
#define pb push_back
#define f first
#define s second
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define trav(i, x) for(auto& i:x)

const int mx = 550;
vector<int> adj[mx], ans;

void dfs(int i, int p) {
	ans.pb(i);
	trav(u, dfs[i]) {
		if (u != p)
			dfs(u);
	}
}

int findEgg (int N, vector < pair < int, int > > bridges)
{
	FOR(i, 0, mx)
		adj[i].clear();
	trav(ii, bridges)
		adj[ii.f].pb(ii.s), adj[ii.s].pb(ii.f);

	dfs(1, 0);

	//2^9=512
	// bin search on search vector for ans
	int lo = 0, hi = ans.size()-1;
	while (lo < hi) {
		int mid = (lo+hi)/2;
		vector<int> cur(ans.begin(), ans.begin()+mid);
		if (query(cur))
			hi = mid;
		else
			lo = mid+1;
	}
}

Compilation message

eastereggs.cpp: In function 'void dfs(int, int)':
eastereggs.cpp:16:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   16 |  trav(u, dfs[i]) {
      |               ^
eastereggs.cpp:9:32: note: in definition of macro 'trav'
    9 | #define trav(i, x) for(auto& i:x)
      |                                ^
eastereggs.cpp:16:15: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   16 |  trav(u, dfs[i]) {
      |               ^
eastereggs.cpp:9:32: note: in definition of macro 'trav'
    9 | #define trav(i, x) for(auto& i:x)
      |                                ^
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:95,
                 from eastereggs.cpp:1:
/usr/include/c++/9/valarray:1224:5: note: 'std::begin' declared here
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
eastereggs.cpp:16:15: error: 'end' was not declared in this scope; did you mean 'std::end'?
   16 |  trav(u, dfs[i]) {
      |               ^
eastereggs.cpp:9:32: note: in definition of macro 'trav'
    9 | #define trav(i, x) for(auto& i:x)
      |                                ^
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:95,
                 from eastereggs.cpp:1:
/usr/include/c++/9/valarray:1244:5: note: 'std::end' declared here
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:42:1: warning: no return statement in function returning non-void [-Wreturn-type]
   42 | }
      | ^