Submission #591468

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

using namespace std;
typedef pair<int,int> pii;
int n,m;
vector<vector<bitset<17>>> 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(auto i:muchii[nod])
    {
        int node=i.to_ulong();
        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(auto i:muchii[nod])
        {
            int x=i.to_ulong();
            if(x==par[nod])
                cnt++;
        }
        if(cnt==1)
            cout<<par[nod]<<' '<<nod<<'\n';
    }
}
bool comp(bitset<17> a, bitset<17> b)
{
    return a.to_ulong()<b.to_ulong();
}
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(),comp);
    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 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1108 KB Output is correct
2 Correct 3 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 161 ms 16244 KB Output is correct
2 Runtime error 193 ms 20508 KB Memory limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 314 ms 22672 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 553 ms 43228 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 798 ms 58728 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 834 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 893 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 991 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 951 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -