답안 #744338

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
744338 2023-05-18T12:39:43 Z MON Easter Eggs (info1cup17_eastereggs) C++17
0 / 100
1 ms 488 KB
#include <vector>
#include<cassert>
#include "grader.h"
using namespace std;
 
vector<int> e,vecini[513];
 
void dfs(int a = 1,int p = -1)
{
    e.emplace_back(a);
    for(auto &it : vecini[a])
        if(it != p) dfs(it,a);
}
 
int findEgg (int N, vector < pair < int, int > > bridges)
{
    for(int i = 1; i <= N ; i++) vecini[i].clear();
    e.clear(); 
    for(auto &it : bridges)
        {
            vecini[it.first].emplace_back(it.second);
            vecini[it.second].emplace_back(it.first);
        }
 
    dfs(1,-1); 
    assert(e.size() == N);
    int ans = -1,pas = 1; while(pas <= N) pas *= 2;
    for(; pas ; pas >>= 1)
        {
            if(ans + pas >= N) continue;
            if(!query(vector<int>(e.begin(),e.begin()+ (ans + pas)))) ans += pas;
        }
 
    return ans + 1;
}

Compilation message

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from grader.h:1,
                 from eastereggs.cpp:3:
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:26:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |     assert(e.size() == N);
      |            ~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 488 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -