Submission #957206

# Submission time Handle Problem Language Result Execution time Memory
957206 2024-04-03T07:22:20 Z LucaIlie Newspapers (CEOI21_newspapers) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 1e3;
bool vis[MAX_N + 1], side[MAX_N + 1];
vector<int> adj[MAX_N + 1];

bool checkBipartite( int u ) {
    vis[u] = true;
    bool ok = true;
    for ( int v: adj[u] ) {
        if ( !vis[v] ) {
            side[v] = side[u] ^ 1;
            ok &= checkBipartite( v );
        } else if ( side[v] == side[u] )
            ok = false;
    }

    return ok;
}

int main() {
    int n, m;

    cin >> n >> m;
    for ( int i = 0; i < m; i++ ) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back( v );
        adj[v].push_back( u );
    }

    if ( m != n - 1 ) {
        cout << "NO\n";
        return 0;
    }

    cout << "YES\n";
    cout << 2 * n - 4 << "\n";
    for ( int i = 2; i <= n - 1; i++ )
        cout << i << " ";
    for ( int i = n - 1; i >= 2; i-- )
        cout << i << " ";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Integer parameter [name=k] equals to -2, violates the range [1, 5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Integer parameter [name=k] equals to -2, violates the range [1, 5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Integer parameter [name=k] equals to -2, violates the range [1, 5]
2 Halted 0 ms 0 KB -