結果

問題 No.583 鉄道同好会
ユーザー t98slidert98slider
提出日時 2023-02-11 20:45:56
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 567 bytes
コンパイル時間 3,908 ms
コンパイル使用メモリ 227,308 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 16:00:52
合計ジャッジ時間 4,819 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 6 ms
4,376 KB
testcase_12 AC 7 ms
4,376 KB
testcase_13 AC 7 ms
4,376 KB
testcase_14 AC 7 ms
4,380 KB
testcase_15 AC 9 ms
4,376 KB
testcase_16 AC 16 ms
4,380 KB
testcase_17 AC 19 ms
4,380 KB
testcase_18 AC 19 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
次のファイルから読み込み:  /usr/include/atcoder/dsu:1,
         次から読み込み:  /usr/include/atcoder/all:2,
         次から読み込み:  main.cpp:2:
メンバ関数 ‘int atcoder::dsu::leader(int)’ 内,
    inlined from ‘int atcoder::dsu::size(int)’ at /usr/include/atcoder/dsu.hpp:44:38,
    inlined from ‘int main()’ at main.cpp:20:91:
/usr/include/atcoder/dsu.hpp:38:29: 警告: ‘r’ may be used uninitialized [-Wmaybe-uninitialized]
   38 |         if (parent_or_size[a] < 0) return a;
      |                             ^
main.cpp: 関数 ‘int main()’ 内:
main.cpp:9:15: 備考: ‘r’ はここで定義されています
    9 |     int n, m, r;
      |               ^

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, r;
    cin >> n >> m;
    vector<int> cnt(n);
    atcoder::dsu uf(n);
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        r = u;
        uf.merge(u, v);
        cnt[u]++, cnt[v]++;
    }
    cout << (count_if(cnt.begin(), cnt.end(), [&](int v){return (v & 1);}) <= 2 && uf.size(r) == count_if(cnt.begin(), cnt.end(), [&](int v){return v >= 1;}) ? "YES" : "NO") << '\n';
}
0