# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
781623 | Andrey | Easter Eggs (info1cup17_eastereggs) | C++14 | 17 ms | 368 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<int> haha[513];
vector<int> bruh(513);
vector<int> wut(0);
int br,p;
void dfs(int a, int t) {
if(p >= br/2) {
return;
}
wut.push_back(a);
if(bruh[a] == 1) {
bruh[a] = 2;
p++;
}
for(int v: haha[a]) {
if(v != t && p < br/2) {
dfs(v,a);
}
}
}
int findEgg (int n, vector < pair < int, int > > bridges)
{
for(int i = 0; i < 513; i++) {
haha[i].clear();
}
int a,b,c;
for(int i = 0; i < n-1; i++) {
a = bridges[i].first;
b = bridges[i].second;
haha[a].push_back(b);
haha[b].push_back(a);
}
for(int i = 1; i <= n; i++) {
bruh[i] = 1;
}
br = n;
p = 0;
while(br > 1) {
wut.clear();
p = 0;
dfs(1,-1);
if(query(wut)) {
c = 2;
}
else {
c = 1;
}
br = 0;
for(int i = 1; i <= n; i++) {
if(bruh[i] != 0) {
if(bruh[i] == c) {
br++;
bruh[i] = 1;
}
else {
bruh[i] = 0;
}
}
}
}
for(int i = 1; i <= n; i++) {
if(bruh[i] == 1) {
return i;
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |