Submission #918064

# Submission time Handle Problem Language Result Execution time Memory
918064 2024-01-29T13:02:26 Z raul2008487 Easter Eggs (info1cup17_eastereggs) C++17
0 / 100
6 ms 10048 KB
#include <bits/stdc++.h>
#include "grader.h"
#define ll int
#define vl vector<ll>
#define fi first
#define se second
#define pb push_back

using namespace std;
const int sz = 2e5+5;
vl adj[sz];
vl et;
void dfs(ll node, ll p){
    et.pb(node);
    for(auto edge: adj[node]){
        if(edge == p){continue;}
        dfs(edge, node);
    }
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
    ll i, j;
    for(i=0;i<bridges.size();i++){
        adj[bridges[i].fi].push_back(bridges[i].se);
        adj[bridges[i].se].push_back(bridges[i].fi);
    }
    dfs(1, 0);
    ll lo = 0, hi = N - 1, mid, best = 0;
    while(lo <= hi){
        mid = (lo + hi) >> 1;
        vl t;
        for(i = lo; i<=mid; i++){
            t.pb(et[i]);
        }
        if(query(t)){
            best = mid;
            hi = mid - 1;
        }
        else{
            lo = mid + 1;
        }
    }
    cout << best << endl;
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:23:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(i=0;i<bridges.size();i++){
      |             ~^~~~~~~~~~~~~~~
eastereggs.cpp:22:11: warning: unused variable 'j' [-Wunused-variable]
   22 |     ll i, j;
      |           ^
eastereggs.cpp:44:1: warning: no return statement in function returning non-void [-Wreturn-type]
   44 | }
      | ^
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 10004 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 10012 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 10048 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -