Submission #550202

# Submission time Handle Problem Language Result Execution time Memory
550202 2022-04-17T14:33:59 Z leaked Pipes (CEOI15_pipes) C++17
40 / 100
1158 ms 65536 KB
#include <bits/stdc++.h>

#define f first
#define s second
#define m_p make_pair
#define vec vector
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pw(x) (1LL<<(x))
#define sz(x) (int)(x).size()

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
template<class T> bool umin(T &a,const T &b){return (a>b?a=b,1:0);}
template<class T> bool umax(T &a,const T &b){return (a<b?a=b,1:0);}
const int N=1e5+1;
vec<pii> g[N];
int fup[N],in[N],tt=2;
struct dsu{
    int p[N];
    dsu(){
        iota(p,p+N,0);
    }
    int get(int v){
        return p[v]=(p[v]==v?v:get(p[v]));
    }
    bool mg(int a,int b){
        a=get(a),b=get(b);
        if(a==b) return 0;
        p[a]=b;
        return 1;
    }
}x,y;
void dfs(int v,int p){
    fup[v]=in[v]=tt++;
    for(auto &z : g[v]){
        if(z.s==p) continue;
        if(in[z.f]) umin(fup[v],in[z.f]);
        else{
            dfs(z.f,z.s);
            umin(fup[v],fup[z.f]);
            if(fup[z.f]>in[v]){
                cout<<v+1<<' '<<z.f+1<<'\n';
            }
        }
    }
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,m;
    int v,u;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>v>>u;--v;--u;
        if(x.mg(v,u) || y.mg(v,u)){
            g[v].pb({u,i});g[u].pb({v,i});
        }
    }
    for(int i=0;i<n;i++){
        if(!in[i])
            dfs(i,i);
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3412 KB Output is correct
2 Correct 2 ms 3412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 3924 KB Output is correct
2 Correct 5 ms 3668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 87 ms 3788 KB Output is correct
2 Correct 85 ms 3676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 155 ms 4688 KB Output is correct
2 Correct 173 ms 4168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 259 ms 6460 KB Output is correct
2 Runtime error 233 ms 19596 KB Memory limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 369 ms 12140 KB Output is correct
2 Runtime error 335 ms 26976 KB Memory limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 583 ms 22228 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 805 ms 59696 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 953 ms 65536 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1158 ms 65536 KB Memory limit exceeded
2 Halted 0 ms 0 KB -