# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
799836 | n3rm1n | Easter Eggs (info1cup17_eastereggs) | C++17 | 13 ms | 628 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"
#define endl '\n'
using namespace std;
const int MAXN = 513;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int n;
vector < int > g[MAXN];
int used[MAXN];
vector < int > a;
void dfs(int beg)
{
used[beg] = 1;
a.push_back(beg);
int nb;
for (int i = 0; i < g[beg].size(); ++ i)
{
nb = g[beg][i];
if(!used[nb])
{
dfs(nb);
}
}
}
int findEgg(int N, vector < pair < int, int > > bridges)
{
n = N;
for (int i = 0; i < bridges.size(); ++ i)
{
int x = bridges[i].first;
int y = bridges[i].second;
g[x].push_back(y);
g[y].push_back(x);
}
dfs(1);
int l = 0, r = n-1, mid;
while(l < r)
{
mid = (l + r)/2;
vector < int > nodes;
for (int i = 0; i <= mid; ++ i)
{
nodes.push_back(a[i]);
}
if(query(nodes) == 1)
{
l = l;
r = mid;
}
else
{
l = mid+1;
r = r;
}
}
return a[l];
}
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... |