Submission #918504

# Submission time Handle Problem Language Result Execution time Memory
918504 2024-01-30T02:01:18 Z vjudge1 Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
12 ms 1776 KB
#include <bits/stdc++.h>
#include "grader.h"
#define ll long long
#define pll pair<ll, ll>
using namespace std;
vector<ll>g[550], eggs;
ll used[550];

void dfs(ll v)
{
    eggs.push_back(v);
    used[v] = 1;
    for (auto u : g[v]){
        if (used[u] == 0){
            dfs(u);
        }
    }
}

int findEgg (int N, vector < pair < int, int > > bridges)
{
    for (ll i = 0; i<bridges.size(); i++){
        g[bridges[i].first].push_back(bridges[i].second);
        g[bridges[i].second].push_back(bridges[i].first);
    }
    dfs(1);
    ll l = 0, r = N - 1;
    while (l < r){
        ll m = (l + r)/2;
        vector<int>f;
        for (ll i = 0; i<m+1; i++){
            f.push_back(eggs[i]);
        }
        if (query(f)){
            r = m;
        }
        else {
            l = m + 1;
        }
    }
    return eggs[l];
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:22:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for (ll i = 0; i<bridges.size(); i++){
      |                    ~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 708 KB Number of queries: 4
2 Correct 1 ms 456 KB Number of queries: 4
3 Correct 1 ms 452 KB Number of queries: 4
4 Correct 1 ms 452 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 3 ms 512 KB Number of queries: 8
2 Correct 8 ms 1212 KB Number of queries: 9
3 Correct 12 ms 1120 KB Number of queries: 9
4 Correct 11 ms 1776 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1100 KB Number of queries: 9
2 Correct 11 ms 1272 KB Number of queries: 9
3 Correct 10 ms 996 KB Number of queries: 9
4 Correct 11 ms 1676 KB Number of queries: 9