Submission #990289

# Submission time Handle Problem Language Result Execution time Memory
990289 2024-05-30T06:11:04 Z xnqs Easter Eggs (info1cup17_eastereggs) C++17
87 / 100
11 ms 608 KB
// omfg why would you use namespace std in a header file like are you ok?????????
// bro why the fuck are you segfaultingggg

#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);

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

int findEgg(int n, std::vector<std::pair<int,int>> bridges) {
	// these testcases are actually fucking retarded, nodes can go above n, like that makes no sense and it's not mentioned in the statement
	// bs problem, average info1cup experience
	std::vector<int> adj_list[513];
	std::vector<int> tour;
	int gs = n;
	for (int i = 0; i < 513; i++) {
		adj_list[i].clear();
	}
	tour.clear();
	for (const auto& [a, b] : bridges) {
		adj_list[a].emplace_back(b);
		adj_list[b].emplace_back(a);
	}
		
	dfs(1,0,adj_list,tour);

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

	ret = tour[ret];
	return ret;
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:29:6: warning: unused variable 'gs' [-Wunused-variable]
   29 |  int gs = n;
      |      ^~
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 344 KB Number of queries: 5
2 Partially correct 1 ms 340 KB Number of queries: 5
3 Partially correct 1 ms 344 KB Number of queries: 5
4 Partially correct 1 ms 344 KB Number of queries: 5
# Verdict Execution time Memory Grader output
1 Correct 4 ms 600 KB Number of queries: 9
2 Correct 7 ms 484 KB Number of queries: 9
3 Correct 11 ms 344 KB Number of queries: 9
4 Correct 9 ms 500 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Partially correct 11 ms 344 KB Number of queries: 10
2 Correct 9 ms 608 KB Number of queries: 9
3 Partially correct 10 ms 488 KB Number of queries: 10
4 Partially correct 10 ms 344 KB Number of queries: 10