제출 #999128

#제출 시각아이디문제언어결과실행 시간메모리
999128crafticatNewspapers (CEOI21_newspapers)C++17
4 / 100
1 ms356 KiB
#include <bits/stdc++.h>

using namespace std;

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

    int n, m; cin >> n >> m;

    vector<vector<int>> g(n + 1);
    for (int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    bool binary = true;
    int spec = 1;
    for (int i = 1; i <= n; ++i) {
        if (g[i].size() > 2) spec++;
    }
    if (spec > 2) binary = false;

    if (m != n - 1 || !binary) {
        cout << "NO\n";
    } else {
        cout << "YES\n";
        cout << "1\n";
        cout << "1\n";
    }

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