답안 #478326

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
478326 2021-10-07T03:28:02 Z hjc4vr Pipes (CEOI15_pipes) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
vector<int> adj[100005];
vector<pair<int,int>> ans;
int low[100005],depths[100005];
 
void dfs(int cur,int par){
    depths[cur] = depths[par] + 1;
    low[cur] = depths[cur];
//    cout << 1;
    for (auto it : adj[cur]){
        if (it!=par){
            if (depths[it]==-1){
                dfs(it,cur);
                low[cur] = min(low[cur],low[it]);
                if (low[it]>depths[cur]){
                    ans.push_back(make_pair(it,cur));
                }
                
            }else{
                low[cur] = min(low[cur],depths[it]);
            }
        }
    }
}
 
 
int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n,m;cin>>n>>m;
    fill(depths,depths+100005,-1);
//    cout << depths[1];
    for (int i=0;i<m;++i){
        int a,b;cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    for (int i=1;i<=n;++i){
        if (depths[x]==-1)dfs(i,i);
    }
    for (auto it:ans){
        int a = it.first, b= it.second;
        if (a<b) swap(a,b);
        cout << b  << " " << a << '\n';
    }
}

Compilation message

pipes.cpp: In function 'int32_t main()':
pipes.cpp:40:20: error: 'x' was not declared in this scope
   40 |         if (depths[x]==-1)dfs(i,i);
      |                    ^