Submission #1108456

# Submission time Handle Problem Language Result Execution time Memory
1108456 2024-11-04T07:40:25 Z simona1230 Duathlon (APIO18_duathlon) C++17
0 / 100
277 ms 20552 KB
#include <bits/stdc++.h>
using namespace std;

vector<int> v[200001];
int n,m;

void read()
{
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
}

int in[200001],low[200001];
int used[200001];
int hey;
int art[200001];

void dfs(int i,int p)
{
    in[i]=hey++;
    low[i]=in[i];
    used[i]=1;

    for(int j=0;j<v[i].size();j++)
    {
        int nb=v[i][j];
        if(!used[nb])
        {
            dfs(nb,i);
            low[i]=min(low[i],low[nb]);
        }
        else if(nb!=p)
        {
            low[i]=min(low[i],in[nb]);
        }
    }

    cout<<i<<" "<<in[i]<<" "<<low[i]<<endl;

    if(low[i]>=in[i])art[i]=1;
}

int main()
{
    read();
    for(int i=1;i<=n;i++)
        if(!used[i])
        {
            dfs(i,-1);
            if(v[i].size()==1)
                art[i]=1;
        }

    for(int i=1;i<=n;i++)
        cout<<art[i]<<" ";
    cout<<endl;
    return 0;
}

Compilation message

count_triplets.cpp: In function 'void dfs(int, int)':
count_triplets.cpp:30:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int j=0;j<v[i].size();j++)
      |                 ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 5968 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 5968 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 231 ms 20552 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 5968 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 277 ms 13640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 5968 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 274 ms 13636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 5968 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 5968 KB Output isn't correct
2 Halted 0 ms 0 KB -