Submission #918342

# Submission time Handle Problem Language Result Execution time Memory
918342 2024-01-29T17:09:56 Z Ferid20072020 Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
2 ms 756 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

int color[513];
vector<vector<int>> g(513);
vector<int> List;

void DFS(int node){
    color[node] = 1;
    List.push_back(node);
    for(auto to : g[node]){
        if(color[to] == 0){
            DFS(to);
        }
    }
}

int findEgg (int N, vector < pair < int, int > > bridges)
{
    List.clear();
    for(int i=1 ; i<=512 ; i++){
        g[i].clear();
    }

    for(int i=0 ; i<bridges.size() ; i++){
        int u = bridges[i].first;
        int v = bridges[i].second;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    DFS(1);


    int l = 0 , r = N - 1;
    while(l < r){
        int mid = (l + r) / 2;
        vector<int> c;
        for(int i=l ; i<=mid ; i++){
            c.push_back(List[i]);
        }
        int ask = query(c);
        if(ask == 1){
            r = mid;
        }
        else{
            l = mid + 1;
        }
    }
    return List[l];
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:27:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i=0 ; i<bridges.size() ; i++){
      |                   ~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Number of queries: 4
2 Runtime error 1 ms 456 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 472 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 756 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -