답안 #527316

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
527316 2022-02-17T05:59:46 Z Hydroxic_Acid Potemkin cycle (CEOI15_indcyc) C++17
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;

int N, R;
vector<int> temp[1005];
vector<int> adjl[1005];
int visited[1005];
vector<int> ans;
queue<pair<int, pair<int, vector<int> > > > q;

void dfs(int idx){
    for(int i = 0; i < (int)temp[idx].size(); i++){
        if((int)adjl[temp[idx][i]].size() == 0){
            adjl[idx].push_back(adjl[idx][i]);
            dfs(adjl[idx][i]);
        }
    }
}

bool dfs2(){
    if(bfs(1)) return true;
    for(int i = 0; i < (int)adjl[1].size(); i++){
        bool result;
        if(visited[adjl[1][i] == 0) result = bfs(adjl[1][i]);
        if(!result) continue;
        else return true;
    }
    return false;
}

bool bfs(int idx){
    vector<int> temp;
    q.push(make_pair(idx, make_pair(idx, temp)));
    while(!q.empty()){
        pair<int, pair<int, vector<int> > > ii = q.front(); q.pop();
        if(ii.first == 1 && ii.second.first < 5) return false;
        if(ii.first == 1 && ii.second.first >= 5){
            ans = ii.second.second; return true;
        }
        if(visited[ii.first] && ii.second.first - visited[ii.first] >= 4){
            ans = ii.second.second; return true;
        }
        if(visited[ii.first] > 0) continue;
        visited[ii.first] = ii.second.first;
        ii.second.second.push_back(ii.first);
        for(int i = 0; i < (int)adjl[ii.first].size(); i++){
            q.push(make_pair(ii.first, make_pair(ii.second.first + 1, ii.second.second)));
        }
    }
    return false;
}

int main(){
    cin >> N >> R;
    for(int i = 0; i < R; i++){
        int a, b; cin >> a >> b;
        adjl[a].push_back(b);
        adjl[b].push_back(a);
    }
    dfs(1);

    if(dfs2()){
        for(int i = 0; i < (int)ans.size(); i++){
            cout << ans[i] << " ";
        }
    }
    else{
        cout << "no";
    }

}

Compilation message

indcyc.cpp: In function 'bool dfs2()':
indcyc.cpp:24:8: error: 'bfs' was not declared in this scope; did you mean 'dfs'?
   24 |     if(bfs(1)) return true;
      |        ^~~
      |        dfs
indcyc.cpp:27:35: error: expected ']' before ')' token
   27 |         if(visited[adjl[1][i] == 0) result = bfs(adjl[1][i]);
      |                                   ^
      |                                   ]
indcyc.cpp:27:46: error: 'bfs' was not declared in this scope; did you mean 'dfs'?
   27 |         if(visited[adjl[1][i] == 0) result = bfs(adjl[1][i]);
      |                                              ^~~
      |                                              dfs