Submission #892750

# Submission time Handle Problem Language Result Execution time Memory
892750 2023-12-25T20:48:17 Z Isam Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
12 ms 1000 KB
#include<bits/stdc++.h>

#ifdef DEBUG
  #include "debug.h"
#else
  #define debug(...) void(37)
#endif

using namespace std;

constexpr int sz = 1001;

#define pii pair<int, int>
#define F first
#define S second

int timel;
int tin[sz];

vector<vector<int>> g;

int query(vector < int > islands);

inline void Dfs(int node, int fa = 1){
	tin[++timel] = node;
	for(auto &to : g[node]){
		if(to == fa) continue;
		Dfs(to, node);
	}
	return;
}

bool Query(int r){
	vector<int> v;
	for(register int i(1); i <= r; ++i) v.emplace_back(tin[i]);
	return query(v);
}

int findEgg(int N, vector < pair < int, int > > bridges){
	g.clear(), timel = 0;
	g.resize(N+1);
	for(register int i(0), a, b; i < N - 1; ++i){
		a = bridges[i].F, b = bridges[i].S;
		g[a].emplace_back(b), g[b].emplace_back(a);
	}
	Dfs(1);
	int l = 1, r = N, mid, best(0);
	while(l < r){
		mid = l + ((r - l) >> 1);
		if(Query(mid)) r = mid;
		else l = mid + 1;
	}
	return tin[l];
}

Compilation message

eastereggs.cpp: In function 'bool Query(int)':
eastereggs.cpp:35:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   35 |  for(register int i(1); i <= r; ++i) v.emplace_back(tin[i]);
      |                   ^
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:42:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   42 |  for(register int i(0), a, b; i < N - 1; ++i){
      |                   ^
eastereggs.cpp:42:25: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   42 |  for(register int i(0), a, b; i < N - 1; ++i){
      |                         ^
eastereggs.cpp:42:28: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   42 |  for(register int i(0), a, b; i < N - 1; ++i){
      |                            ^
eastereggs.cpp:47:25: warning: unused variable 'best' [-Wunused-variable]
   47 |  int l = 1, r = N, mid, best(0);
      |                         ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Number of queries: 4
2 Correct 1 ms 344 KB Number of queries: 4
3 Correct 0 ms 344 KB Number of queries: 4
4 Correct 1 ms 344 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 3 ms 972 KB Number of queries: 8
2 Correct 8 ms 984 KB Number of queries: 9
3 Correct 12 ms 740 KB Number of queries: 9
4 Correct 12 ms 732 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 12 ms 752 KB Number of queries: 9
2 Correct 12 ms 996 KB Number of queries: 9
3 Correct 11 ms 736 KB Number of queries: 9
4 Correct 12 ms 1000 KB Number of queries: 9