# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
920597 | DON_F | Easter Eggs (info1cup17_eastereggs) | C++14 | 1 ms | 496 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;
using ll = long long;
#define F first
#define S second
vector < vector < int > > g;
set < int > cur, sp;
vector < int > all, vis;
ll p;
void dfs(int u){
if ((int) sp.size() == p){
return;
}
all.push_back(u);
if (cur.count(u)){
sp.insert(u);
}
for (auto &i : g[u]){
dfs(i);
}
}
int findEgg (int n, vector < pair < int, int > > z){
for (int i = 1; i <= n; ++i){
cur.insert(i);
}
g = vector < vector < int > > (n + 1);
ll lg = ceil(log2(n)), c = 0;
for (int i = 0; i < n - 1; ++i){
g[z[i].F].push_back(z[i].S);
}
while (cur.size() != 1 && lg){
p = cur.size() / 2;
for (int i = 1; i <= n; ++i){
dfs(i);
if ((int) sp.size() == p){
break;
}
sp.clear();
all.clear();
}
ll tmp = query(all);
if (tmp){
cur.clear();
for (auto &i : sp){
cur.insert(i);
}
}else{
for (auto &i : sp){
cur.erase(i);
}
}
sp.clear();
all.clear();
lg--;
}
return *cur.begin();
}
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... |