Submission #799723

# Submission time Handle Problem Language Result Execution time Memory
799723 2023-07-31T21:07:33 Z Johann Newspapers (CEOI21_newspapers) C++14
4 / 100
9 ms 452 KB
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

int N, M;
vvi adj;
bool possible;
vi cnt[2];

void dfs(int v, int p)
{
    cnt[0][v] = 1;
    cnt[1][v] = 0;
    for (int u : adj[v])
        if (u != p)
        {
            dfs(u, v);
            cnt[0][v] += cnt[1][u];
            cnt[1][v] += cnt[0][u];
        }
}

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

    cin >> N >> M;
    if (M > N - 1)
    {
        cout << "NO\n";
        return 0;
    }

    adj.resize(N);

    for (int i = 0, a, b; i < M; ++i)
    {
        cin >> a >> b;
        --a, --b;
        adj[a].push_back(b), adj[b].push_back(a);
    }

    possible = true;
    cnt[0].resize(N), cnt[1].resize(N);
    for (int v = 0; v < N; ++v)
    {
        dfs(v, v);
        int crit = 0;
        for (int u : adj[v])
            if (cnt[1][u] >= 2)
                ++crit;
        if (crit > 2)
            possible = false;
    }

    if (possible)
    {
        cout << "YES\n";

        vi ans;
        ans.push_back(0);
        cout << sz(ans) << '\n';
        for (int x : ans)
            cout << x + 1 << " ";
        cout << '\n';
    }
    else
        cout << "NO\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Partially correct 1 ms 212 KB Failed to provide a successful strategy.
3 Partially correct 1 ms 316 KB Failed to provide a successful strategy.
4 Partially correct 1 ms 212 KB Failed to provide a successful strategy.
5 Partially correct 1 ms 212 KB Failed to provide a successful strategy.
6 Partially correct 1 ms 212 KB Failed to provide a successful strategy.
7 Correct 1 ms 212 KB Output is correct
8 Partially correct 1 ms 212 KB Failed to provide a successful strategy.
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Partially correct 1 ms 212 KB Failed to provide a successful strategy.
3 Partially correct 1 ms 340 KB Failed to provide a successful strategy.
4 Partially correct 1 ms 212 KB Failed to provide a successful strategy.
5 Partially correct 1 ms 320 KB Failed to provide a successful strategy.
6 Partially correct 1 ms 212 KB Failed to provide a successful strategy.
7 Partially correct 1 ms 212 KB Failed to provide a successful strategy.
8 Partially correct 0 ms 212 KB Failed to provide a successful strategy.
9 Partially correct 0 ms 212 KB Failed to provide a successful strategy.
10 Partially correct 0 ms 212 KB Failed to provide a successful strategy.
11 Partially correct 7 ms 440 KB Failed to provide a successful strategy.
12 Partially correct 3 ms 340 KB Failed to provide a successful strategy.
13 Partially correct 3 ms 340 KB Failed to provide a successful strategy.
14 Partially correct 4 ms 340 KB Failed to provide a successful strategy.
15 Partially correct 4 ms 340 KB Failed to provide a successful strategy.
16 Partially correct 8 ms 340 KB Failed to provide a successful strategy.
17 Partially correct 8 ms 452 KB Failed to provide a successful strategy.
18 Partially correct 9 ms 452 KB Failed to provide a successful strategy.
19 Partially correct 8 ms 448 KB Failed to provide a successful strategy.
20 Partially correct 8 ms 340 KB Failed to provide a successful strategy.
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Partially correct 1 ms 212 KB Failed to provide a successful strategy.
3 Partially correct 1 ms 316 KB Failed to provide a successful strategy.
4 Partially correct 1 ms 212 KB Failed to provide a successful strategy.
5 Partially correct 1 ms 212 KB Failed to provide a successful strategy.
6 Partially correct 1 ms 212 KB Failed to provide a successful strategy.
7 Correct 1 ms 212 KB Output is correct
8 Partially correct 1 ms 212 KB Failed to provide a successful strategy.
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -