제출 #1324600

#제출 시각아이디문제언어결과실행 시간메모리
1324600eri16수천개의 섬 (IOI22_islands)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 100001;

int out_deg[MAXN];
vector<int> in_adj[MAXN];
vector<int> out_adj[MAXN];
char deleted[MAXN];
queue<int> events;

void delete_vertex(int x){
    if (deleted[x]) return;
    deleted[x]=1;
    for (int p : in_adj[x]) {
        out_deg[p]--;
        if (out_deg[p]==0) events.push(p);
    }
}

int extend_from(int v){
    int last_next=-1;
    for (int to : out_adj[v]){
        if (deleted[to]) continue;
        last_next=to;
    }
    delete_vertex(v);
    return last_next;
}

pair<bool, vector<int>> find_journey_exists(int n, int m, const vector<int>& U, const vector<int>& V) {

    for (int i=0; i<n; i++){
        out_deg[i] = 0;
        in_adj[i].clear();
        out_adj[i].clear();
        deleted[i] = 0;
    }
    while (!events.empty()) events.pop();

    for (int i=0; i<m; i++){
        out_adj[U[i]].push_back(V[i]);
        out_deg[U[i]]++;
        in_adj[V[i]].push_back(U[i]);
    }

    for (int i=0; i<n; i++)
        if (out_deg[i]==0) events.push(i);

    int current=0;
    
    while (out_deg[current]<=1){
        int next=extend_from(current);
        if (next==-1) return false;
        current=next;
    }

    while (!events.empty()){
        int x=events.front();
        events.pop();
        if (deleted[x]) continue;
        delete_vertex(x);

        while (out_deg[current]<=1){
            int next=extend_from(current);
            if (next==-1) return false;
            current=next;
        }
    }
    vector <int> vvv;
    return {true,vvv};
}

컴파일 시 표준 에러 (stderr) 메시지

islands.cpp: In function 'std::pair<bool, std::vector<int> > find_journey_exists(int, int, const std::vector<int>&, const std::vector<int>&)':
islands.cpp:54:30: error: could not convert 'false' from 'bool' to 'std::pair<bool, std::vector<int> >'
   54 |         if (next==-1) return false;
      |                              ^~~~~
      |                              |
      |                              bool
islands.cpp:66:34: error: could not convert 'false' from 'bool' to 'std::pair<bool, std::vector<int> >'
   66 |             if (next==-1) return false;
      |                                  ^~~~~
      |                                  |
      |                                  bool