제출 #593975

#제출 시각아이디문제언어결과실행 시간메모리
593975vladislav11Newspapers (CEOI21_newspapers)C++14
0 / 100
1 ms320 KiB
#include <bits/stdc++.h>

using namespace std;

int n, m;
vector< vector<int> > grp;
vector<int> used;

void dfs ( int v, int p )
{
    used[v] = 1;

    for ( auto& to : grp[v] )
    if ( to != p )
    {
        if ( used[to] )
        {
            cout << "NO\n";
            exit(0);
        }

        dfs( to, v );
    }
}

int main ()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> m;

    grp.resize( n+1 );

    for ( int i=0; i<m; i++ )
    {
        int u, v;
        cin >> u >> v;

        grp[u].push_back( v );
        grp[v].push_back( u );
    }

    used.assign( n+1, 0 );

    dfs( 1, -1 );

    cout << "YES 0";

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...