Submission #591470

# Submission time Handle Problem Language Result Execution time Memory
591470 2022-07-07T13:10:47 Z andrei_boaca Pipes (CEOI15_pipes) C++14
50 / 100
4476 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()
{
    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 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 852 KB Output is correct
2 Correct 7 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 362 ms 4612 KB Output is correct
2 Correct 312 ms 4132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 672 ms 6876 KB Output is correct
2 Correct 650 ms 8700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 937 ms 13712 KB Output is correct
2 Correct 796 ms 12072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1233 ms 27472 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1921 ms 65192 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2949 ms 65536 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3539 ms 65536 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4476 ms 65536 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -