Submission #990271

# Submission time Handle Problem Language Result Execution time Memory
990271 2024-05-30T05:35:12 Z xnqs Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
1 ms 600 KB
// omfg why would you use namespace std in a header file like are you ok?????????

#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
#include "grader.h"

//int findEgg(int n, std::vector<std::pair<int,int>> bridges);
//int query(std::vector<int> islands);

int gs;
std::vector<std::vector<int>> adj_list;
std::vector<int> tour;

void dfs(int k, int p, int& timer) {
	tour.emplace_back(k);
	for (const auto& i : adj_list[k]) {
		if (i!=p) {
			dfs(i,k,timer);
			tour.emplace_back(k);
		}
	}
}

int findEgg(int n, std::vector<std::pair<int,int>> bridges) {
	gs = n;
	adj_list.clear(); adj_list.resize(gs+1);
	for (const auto& [a, b] : bridges) {
		adj_list[a].emplace_back(b);
		adj_list[b].emplace_back(a);
	}

	{ int timer = 0; dfs(1,0,timer); };

	int l = 0, r = tour.size()-1;
	int ret = 0;
	while (l<=r) {
		int m = (l+r)/2;
		std::vector<int> tmp;
		for (int i = l; i <= m; i++) {
			tmp.emplace_back(tour[i]);
		}
		if (query(tmp)) {
			ret = m;
			r = m-1;
		}
		else {
			l = m+1;
		}
	}

	return tour[ret];
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:31:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   31 |  for (const auto& [a, b] : bridges) {
      |                   ^
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -