Submission #591469

# Submission time Handle Problem Language Result Execution time Memory
591469 2022-07-07T13:08:17 Z andrei_boaca Pipes (CEOI15_pipes) C++14
30 / 100
2240 ms 65536 KB
#include <bits/stdc++.h>
 
using namespace std;
typedef pair<int,int> pii;
int n,m;
vector<vector<short>> muchii;
bool use[100005];
int topar[100005],par[100005];
int niv[100005],nivmin[100005];
void dfs(int nod)
{
    use[nod]=1;
    nivmin[nod]=niv[nod];
    for(int i:muchii[nod])
    {
        int node=i;
        if(node==par[nod])
            continue;
        if(!use[node])
        {
            par[node]=nod;
            niv[node]=niv[nod]+1;
            dfs(node);
            nivmin[nod]=min(nivmin[nod],nivmin[node]);
        }
        else
            nivmin[nod]=min(nivmin[nod],niv[node]);
    }
    int cnt=0;
    if(nivmin[nod]==niv[nod]&&par[nod]!=0)
    {
        for(int i:muchii[nod])
            if(i==par[nod])
                cnt++;
        if(cnt==1)
            cout<<par[nod]<<' '<<nod<<'\n';
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m;
    muchii.resize(n+1);
    for(int i=1;i<=m;i++)
    {
        int a,b;
        cin>>a>>b;
        muchii[a].push_back(b);
        muchii[b].push_back(a);
    }
    for(int i=1;i<=n;i++)
        sort(muchii[i].begin(),muchii[i].end());
    for(int i=1;i<=n;i++)
        if(!use[i])
        {
            niv[i]=1;
            dfs(i);
        }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 852 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 131 ms 4636 KB Output is correct
2 Correct 158 ms 4224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 234 ms 6964 KB Output is correct
2 Runtime error 279 ms 20080 KB Memory limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 402 ms 13932 KB Output is correct
2 Runtime error 336 ms 25884 KB Memory limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 541 ms 27488 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1150 ms 65536 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1465 ms 65536 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1846 ms 65536 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2240 ms 65536 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -