답안 #560687

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
560687 2022-05-11T22:57:35 Z urosk Pipes (CEOI15_pipes) C++14
0 / 100
928 ms 7920 KB
// __builtin_popcount(x)
// __builtin_popcountll(x)
#define here cerr<<"===========================================\n"
#include <bits/stdc++.h>
#define ld double
#define ll int
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
using namespace std;

#define maxn 100005
ll n,m;
ll dsu[maxn];
ll dsu2[maxn];
vector<ll> g[maxn];
ll low[maxn];
ll in[maxn];
ll root(ll x,ll* dsu){
    while(x!=dsu[x]){
       dsu[x] = dsu[dsu[x]];
       x = dsu[x];
    }
    return x;
}
void upd(ll x,ll y,ll* dsu){
    x = root(x,dsu);
    y = root(y,dsu);
    dsu[y] = x;
}
bool get(ll x,ll y,ll* dsu){return root(x,dsu)==root(y,dsu);}
ll it = 1;
void dfs(ll u,ll par){
    in[u] = low[u] = it++;
    bool bio = 0;
    for(ll s : g[u]){
        if(s==par&&!bio){bio = 1;continue;}
        if(in[s]!=0) dfs(s,u);
        low[u] = min(low[u],low[s]);
    }
    if(u!=par&&low[u]>in[par]) cout<<u<< " "<<par<<endl;
}
int main(){
	ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);
    cin >> n >> m;
    iota(dsu+1,dsu+n+1,1);
    iota(dsu2+1,dsu2+n+1,1);
    for(ll i = 1;i<=m;i++){
        ll x,y; cin >> x >> y;
        if(get(x,y,dsu)){
            if(get(x,y,dsu2)) continue;
            upd(x,y,dsu2);
        }else upd(x,y,dsu);
        g[x].pb(y);
        g[y].pb(x);
    }
    for(ll i = 1;i<=n;i++) if(in[i]!=0) dfs(i,i);
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2644 KB Wrong number of edges
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 2932 KB Wrong number of edges
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 83 ms 3064 KB Output is correct
2 Incorrect 80 ms 3016 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 142 ms 3276 KB Output is correct
2 Incorrect 166 ms 3536 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 227 ms 3996 KB Output is correct
2 Incorrect 214 ms 4292 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 335 ms 6016 KB Output is correct
2 Incorrect 281 ms 5948 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 494 ms 6548 KB Output is correct
2 Incorrect 476 ms 6552 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 646 ms 7708 KB Output is correct
2 Incorrect 583 ms 7920 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 797 ms 7748 KB Output is correct
2 Incorrect 804 ms 7448 KB Wrong number of edges
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 928 ms 7320 KB Output is correct
2 Incorrect 890 ms 7028 KB Wrong number of edges
3 Halted 0 ms 0 KB -