Submission #713037

# Submission time Handle Problem Language Result Execution time Memory
713037 2023-03-21T00:34:39 Z vjudge1 Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
21 ms 628 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
const int maxn = 1010;
typedef pair<int,int> ii;
#define ff first
#define ss second
int n;
vector <int> question;
int dau[maxn],s[maxn];
vector <int> adj[maxn],comp;
void dfs(int x, int p)
{
    comp.push_back(x);
    for (int i:adj[x])
        if (i!=p) dfs(i,x);
}
int findEgg(int N, vector <ii> bridges)
{
    n=N;
    question.clear();
    for (int i=1; i<=n; i++) adj[i].clear();
    for (ii i:bridges)
    {
        adj[i.ff].push_back(i.ss);
        adj[i.ss].push_back(i.ff);
    }
    dfs(1,1);
    int l=0; int r=n-1;
    int ans = -1;
    while (l<r)
    {
        int mid=(l+r)/2;
        vector <int> tmp;
        for (int i=0; i<=mid; i++) tmp.push_back(comp[i]);
        if (query(tmp)) r=mid;
        else l=mid+1;
    }
    return comp[r];
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:30:9: warning: unused variable 'ans' [-Wunused-variable]
   30 |     int ans = -1;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Number of queries: 4
2 Correct 1 ms 208 KB Number of queries: 4
3 Correct 1 ms 208 KB Number of queries: 4
4 Correct 1 ms 336 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 5 ms 408 KB Number of queries: 8
2 Correct 14 ms 444 KB Number of queries: 9
3 Correct 18 ms 628 KB Number of queries: 9
4 Correct 13 ms 476 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 20 ms 544 KB Number of queries: 9
2 Correct 21 ms 464 KB Number of queries: 9
3 Correct 15 ms 576 KB Number of queries: 9
4 Correct 15 ms 584 KB Number of queries: 9