답안 #918903

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
918903 2024-01-30T17:40:47 Z Moonn Easter Eggs (info1cup17_eastereggs) C++17
0 / 100
2 ms 1068 KB
#include<bits/stdc++.h>
#define inti long long
#define AI ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
vector<vector<int>>v;
vector<bool>ch;
vector<int>g;
int query(vector<int> islands);
void dfs(int n,int x)
{
    ch[x]=1;
    for(int i:v[x])
    {
        if(!ch[i])
        dfs(n,i);
    }
    g.push_back(x);
}
int findEgg(int n, vector < pair < int, int > > bridges)
{
    v.resize(n+1);
    ch.resize(n+1,0);
    for(int i=0;i<bridges.size();i++)
    {
        int a=bridges[i].first;
        int b=bridges[i].second;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    dfs(n,1);
    int l,r,mid;
    l=0;
    r=g.size()-1;
    vector<int>vi;
    while(l<r)
    {
        vi.clear();
        mid=(l+r)/2;
        for(int i=0;i<=mid;i++)
        vi.push_back(g[i]);
        if(query(vi))
        r=mid;
        else
        l=mid+1;
    }
    return g[l];
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:23:18: 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(int i=0;i<bridges.size();i++)
      |                 ~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 436 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 2 ms 1068 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -