Submission #998353

#TimeUsernameProblemLanguageResultExecution timeMemory
998353andrei_iorgulescuNewspapers (CEOI21_newspapers)C++14
4 / 100
1 ms408 KiB
#include <bits/stdc++.h>

using namespace std;

int n,m;
vector<int> g[1005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> m;
    for (int i = 1; i <= m; i++)
    {
        int x,y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    if (m != n - 1)
    {
        cout << "NO";
        return 0;
    }
    int nrgr = 0;
    for (int i = 1; i <= n; i++)
        if (g[i].size() >= 3)
            nrgr++;
    if (nrgr > 1)
    {
        cout << "NO";
        return 0;
    }
    cout << "YES\n1\n1";
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...