답안 #875720

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
875720 2023-11-20T11:48:14 Z Aiperiii Easter Eggs (info1cup17_eastereggs) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
//#include "grader.h"
using namespace std;
int findEgg (int N, vector < pair < int, int > > bridges)
{
    vector <int> g[N+1];
    for(int i=0;i<bridges.size();i++){
        g[bridges[i].first].push_back(bridges[i].second);
        g[bridges[i].second].push_back(bridges[i].first);
    }

    vector <int> vec,vis(N+1);
    queue <int> q;
    queue <vector <int> > d;
    for(int i=1;i<=N;i++){
        if(vis[i]==0){
            q.push(i);
            while(!q.empty()){
                int v=q.front();
                q.pop();
                vec.push_back(v);
                vis[v]=1;
                for(auto to : g[v]){
                    if(vis[to]==0){
                        q.push(to);
                        break;
                    }
                }
            }
            d.push(vec);
            vec.clear();
        }
    }
    while(!d.empty()){
        vector <int> v=d.front();
        d.pop();
        if(query(v)==1){
            if(v.size()==1){
                cout<<v[0]<<endl;exit(0);
            }
            else{
                int x=(v.size()+1)/2;
                vector <int> s;
                while(s.size()<x){
                    s.push_back(v.back());
                    v.pop_back();
                }
                d.push(v);
                d.push(s);
            }
        }
    }
    return 0;
}


Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:7: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]
    7 |     for(int i=0;i<bridges.size();i++){
      |                 ~^~~~~~~~~~~~~~~
eastereggs.cpp:37:12: error: 'query' was not declared in this scope
   37 |         if(query(v)==1){
      |            ^~~~~
eastereggs.cpp:44:31: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |                 while(s.size()<x){
      |                       ~~~~~~~~^~