Submission #243025

# Submission time Handle Problem Language Result Execution time Memory
243025 2020-06-30T07:56:43 Z umk Easter Eggs (info1cup17_eastereggs) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include "grader.h"

#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;

const int N = 1e5+5;
int ck[N], nw[N], cnt, cur;
vector <int> adj[N];

void dfs(int u, int p){
	if (cur == num) return ;
	if (ck[u]) cur++;
	ans.pb(u);
	for (int i=0; i<(int)adj[u].size(); i++){
		int v = adj[u][i];
		if (v == p) continue;
		dfs(v, u);
	}
}

int findEgg(int n, vector <pair <int, int> bridges){
	for (int i=1; i<=n; i++) ck[i] = 1;
	cnt = n;
	for (int i=1; i<=n; i++) adj[i].clear();
	for (int i=1; i<n; i++){
		adj[bridges[i-1].fi].pb(bridges[i-1].se);
		adj[bridges[i-1].se].pb(bridges[i-1].fi);
	} 
	while (cnt != 1){
		num = (cnt+1)>>1; cur = 0;
		ans.clear();
		dfs(1, 1);
		if (query(ans)){
			for (int i=1; i<=n; i++) nw[i] = 0;
			for (int i=0; i<(int)ans.size(); i++) nw[ans[i]] = ck[ans[i]];
			for (int i=1; i<=n; i++) ck[i] = nw[i];
			cnt = num;
		}
		else{
			for (int i=0; i<(int)ans.size(); i++) ck[ans[i]] = 0;
			cnt -= num;
		}
	}
	for (int i=1; i<=n; i++) if (ck[i]) return i;
}

Compilation message

eastereggs.cpp: In function 'void dfs(long long int, long long int)':
eastereggs.cpp:17:13: error: 'num' was not declared in this scope
  if (cur == num) return ;
             ^~~
eastereggs.cpp:17:13: note: suggested alternative: 'enum'
  if (cur == num) return ;
             ^~~
             enum
eastereggs.cpp:19:2: error: 'ans' was not declared in this scope
  ans.pb(u);
  ^~~
eastereggs.cpp:19:2: note: suggested alternative: 'abs'
  ans.pb(u);
  ^~~
  abs
eastereggs.cpp: At global scope:
eastereggs.cpp:27:44: error: template argument 1 is invalid
 int findEgg(int n, vector <pair <int, int> bridges){
                                            ^~~~~~~
eastereggs.cpp:27:44: error: template argument 2 is invalid
eastereggs.cpp:27:44: error: template argument 1 is invalid
eastereggs.cpp:27:44: error: template argument 2 is invalid
eastereggs.cpp:27:44: error: template argument 1 is invalid
eastereggs.cpp:27:44: error: template argument 2 is invalid
eastereggs.cpp:27:20: error: 'vector' is not a type
 int findEgg(int n, vector <pair <int, int> bridges){
                    ^~~~~~
eastereggs.cpp:27:27: error: expected ',' or '...' before '<' token
 int findEgg(int n, vector <pair <int, int> bridges){
                           ^
eastereggs.cpp: In function 'long long int findEgg(long long int, int)':
eastereggs.cpp:32:7: error: 'bridges' was not declared in this scope
   adj[bridges[i-1].fi].pb(bridges[i-1].se);
       ^~~~~~~
eastereggs.cpp:36:3: error: 'num' was not declared in this scope
   num = (cnt+1)>>1; cur = 0;
   ^~~
eastereggs.cpp:36:3: note: suggested alternative: 'enum'
   num = (cnt+1)>>1; cur = 0;
   ^~~
   enum
eastereggs.cpp:37:3: error: 'ans' was not declared in this scope
   ans.clear();
   ^~~
eastereggs.cpp:37:3: note: suggested alternative: 'abs'
   ans.clear();
   ^~~
   abs
eastereggs.cpp:51:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^