답안 #231759

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
231759 2020-05-14T15:49:20 Z mehrdad_sohrabi Pipes (CEOI15_pipes) C++14
0 / 100
56 ms 65540 KB
#include <bits/stdc++.h>
typedef int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define endl '\n'
//#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=6e6+10;
ll par1[N],par2[N];
ll get1(ll v){
    if (par1[v]==v) return v;
    return par1[v]=get1(par1[v]);
}
ll get2(ll v){
    if (par2[v]==v) return v;
    return par2[v]=get2(par2[v]);
}
vector <int> g[N];
ll vis[N];
ll hi[N];
ll ma[N];
ll dfs(ll v,ll p,ll h){
    vis[v]=1;
    hi[v]=h;
    ll p1=0;
    ma[v]=h-1;
    for (auto u : g[v]){
        if (u==p){
            p1++;
            continue;
        }
        if (vis[u]==0){
            dfs(u,v,h+1);
            ma[v]=min(ma[v],ma[u]);
            if (ma[u]<=h-1) p1+=2;
        }
        else if (hi[u]<hi[v]){
            p1+=2;
            ma[v]=min(ma[v],hi[u]);
        }
    }
   // cout << v << " jn " <<  ma[v] << endl;
    if (p1<2 && p!=0){
        cout << p << " " << v << endl;
    }

}
int32_t main(){
    sync;
    ll n,m;
    cin >> n >> m;
    for (int i=0;i<N;i++) par1[i]=i,par2[i]=i;
    for (int i=0;i<m;i++){
        ll u,v;
        cin >> u >> v;
        ll u1=get1(u),v1=get1(v);
        if (u1!=v1){
            g[u].pb(v);
            g[v].pb(u);
            par1[u1]=v1;
            continue;
        }
        u1=get2(u),v1=get2(v);
        if (u1!=v1){
            g[u].pb(v);
            g[v].pb(u);
            par2[u1]=v1;
        }
    }
    for (int i=1;i<=n;i++) if (!vis[i]) dfs(i,0,0);
}

Compilation message

pipes.cpp: In function 'll dfs(ll, ll, ll)':
pipes.cpp:54:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 46 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 44 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 38 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 56 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 44 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 41 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 47 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 41 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 44 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 50 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -