답안 #874280

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
874280 2023-11-16T15:36:01 Z asli_bg Easter Eggs (info1cup17_eastereggs) C++11
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

//int query(vector < int > islands);

int findEgg (int N, vector < pair < int, int > > bridges)
{

    if(N==2){
        if(query(bridges[0].fi)){
            return bridges[0].fi;
        }
        else return bridges[0].se;
    }
    
    set<int> s;
    set<int> bridge_ind;
    vector<int> islands;
    //vector<int> adjlist[550];

    /*for(auto el:bridges){
        adjlist[el.fi].pb(el.se);
        adjlist[el.se].pb(el.fi);
    }*/

    //int j=1;

    //while(s.size()<N/2){
        
        for(int i=0;i<bridges.size() and s.size()<N/2;i++){
            int sz=s.size();
            s.insert(bridges[i].fi);
            s.insert(bridges[i].se);
            bridge_ind.insert(i);
            if(sz!=0 and s.size()-sz==2){
                s.erase(bridges[i].fi);
                s.erase(bridges[i].se);
                bridge_ind.erase(i);
            }
        }



    //}

    for(auto el:s){
        islands.push_back(el);
    }

    vector<pair<int,int>> new_bridge;

    if(query(islands)){
        for(auto el:bridge_ind){
            new_bridge.push_back(bridges[el]);
        }

        findEgg(islands.size(),new_bridge);
    }
    else{
        for(int i=1;i<=N;i++){
            if(!bridge_int.count(i)){
                new_bridge.push_back(bridges[i]);
            }
        }

        findEgg(N-islands.size(),new_bridge);
    }


    //if (query ({1})) return 1;
    //return N;
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:11:29: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'fi'
   11 |         if(query(bridges[0].fi)){
      |                             ^~
eastereggs.cpp:12:31: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'fi'
   12 |             return bridges[0].fi;
      |                               ^~
eastereggs.cpp:14:32: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'se'
   14 |         else return bridges[0].se;
      |                                ^~
eastereggs.cpp:31:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for(int i=0;i<bridges.size() and s.size()<N/2;i++){
      |                     ~^~~~~~~~~~~~~~~
eastereggs.cpp:31:50: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   31 |         for(int i=0;i<bridges.size() and s.size()<N/2;i++){
      |                                          ~~~~~~~~^~~~
eastereggs.cpp:33:33: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'fi'
   33 |             s.insert(bridges[i].fi);
      |                                 ^~
eastereggs.cpp:34:33: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'se'
   34 |             s.insert(bridges[i].se);
      |                                 ^~
eastereggs.cpp:37:36: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'fi'
   37 |                 s.erase(bridges[i].fi);
      |                                    ^~
eastereggs.cpp:38:36: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'se'
   38 |                 s.erase(bridges[i].se);
      |                                    ^~
eastereggs.cpp:62:17: error: 'bridge_int' was not declared in this scope; did you mean 'bridge_ind'?
   62 |             if(!bridge_int.count(i)){
      |                 ^~~~~~~~~~
      |                 bridge_ind