結果

問題 No.583 鉄道同好会
ユーザー kyunakyuna
提出日時 2019-08-12 06:29:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 583 bytes
コンパイル時間 725 ms
コンパイル使用メモリ 74,608 KB
実行使用メモリ 4,540 KB
最終ジャッジ日時 2023-10-12 18:48:18
合計ジャッジ時間 1,876 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 13 ms
4,348 KB
testcase_12 AC 18 ms
4,348 KB
testcase_13 AC 18 ms
4,348 KB
testcase_14 AC 18 ms
4,348 KB
testcase_15 AC 22 ms
4,352 KB
testcase_16 AC 41 ms
4,540 KB
testcase_17 AC 49 ms
4,536 KB
testcase_18 AC 49 ms
4,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

bool euler_path(vector<vector<int>> &g, int s = -1) {
    vector<int> cnt(2);
    for (auto &v: g) cnt[v.size() % 2]++;
    if (cnt[1] == 0) return true;
    if (cnt[1] == 2 && (s == -1 || g[s].size() % 2 == 1)) return true;
    return false;
}

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int>> g(n);
    while (m--) {
        int a, b; cin >> a >> b;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    cout << (euler_path(g) ? "YES" : "NO") << endl;
    return 0;
}
0