제출 #999114

#제출 시각아이디문제언어결과실행 시간메모리
999114crafticatNewspapers (CEOI21_newspapers)C++17
4 / 100
1 ms348 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() == 3) spec++;
        if (g[i].size() > 3) binary = false;
    }
    if (spec > 1) binary = false;

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

    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

newspapers.cpp: In function 'int main()':
newspapers.cpp:16:10: warning: variable 'binary' set but not used [-Wunused-but-set-variable]
   16 |     bool binary = true;
      |          ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...