Submission #591460

# Submission time Handle Problem Language Result Execution time Memory
591460 2022-07-07T12:52:41 Z andrei_boaca Pipes (CEOI15_pipes) C++14
20 / 100
968 ms 65536 KB
#include <bits/stdc++.h>

using namespace std;
typedef pair<int,int> pii;
int n,m;
vector<pii> muchii[100005];
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(auto i:muchii[nod])
    {
        int node=i.first,index=i.second;
        if(index==topar[nod])
            continue;
        if(!use[node])
        {
            par[node]=nod;
            topar[node]=index;
            niv[node]=niv[nod]+1;
            dfs(node);
            nivmin[nod]=min(nivmin[nod],nivmin[node]);
        }
        else
            nivmin[nod]=min(nivmin[nod],niv[node]);
    }
    if(nivmin[nod]==niv[nod]&&par[nod]!=0)
        cout<<par[nod]<<' '<<nod<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int a,b;
        cin>>a>>b;
        muchii[a].push_back({b,i});
        muchii[b].push_back({a,i});
    }
    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 2 ms 2676 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 3432 KB Output is correct
2 Correct 5 ms 3212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 113 ms 23988 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 218 ms 34504 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 360 ms 61348 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 661 ms 65536 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 830 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 961 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 968 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 892 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -