結果

問題 No.2418 情報通だよ!Nafmoくん
ユーザー xueleixuelei
提出日時 2023-08-12 13:53:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 974 bytes
コンパイル時間 1,648 ms
コンパイル使用メモリ 171,572 KB
実行使用メモリ 11,988 KB
最終ジャッジ日時 2024-04-30 04:25:35
合計ジャッジ時間 3,228 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,192 KB
testcase_01 AC 4 ms
8,064 KB
testcase_02 AC 4 ms
8,064 KB
testcase_03 AC 56 ms
11,648 KB
testcase_04 AC 10 ms
8,576 KB
testcase_05 AC 34 ms
10,796 KB
testcase_06 AC 34 ms
10,624 KB
testcase_07 AC 36 ms
10,880 KB
testcase_08 AC 35 ms
10,708 KB
testcase_09 AC 48 ms
11,648 KB
testcase_10 AC 58 ms
11,772 KB
testcase_11 AC 47 ms
11,156 KB
testcase_12 AC 29 ms
10,324 KB
testcase_13 AC 14 ms
9,112 KB
testcase_14 AC 26 ms
9,908 KB
testcase_15 AC 20 ms
9,448 KB
testcase_16 AC 59 ms
11,988 KB
testcase_17 AC 15 ms
9,088 KB
testcase_18 AC 27 ms
10,032 KB
testcase_19 AC 7 ms
8,320 KB
testcase_20 AC 22 ms
9,456 KB
testcase_21 AC 18 ms
9,344 KB
testcase_22 AC 19 ms
9,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = (int)(a); (i) < (int)(b); (i)++)
#define rrep(i, a, b) for (int i = (int)(b) - 1; (i) >= (int)(a); (i)--)
#define all(v) v.begin(), v.end()

typedef long long ll;
template <class T> using V = vector<T>;
template <class T> using VV = vector<V<T>>;

V<int> G[200010];
V<bool> used(200010);
int nc = 0;

void f(int k) {
    used[k] = 1;
    nc++;
    rep(i,0,G[k].size()) {
        int to = G[k][i];
        if (used[to]) continue;
        f(to);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    constexpr char endl = '\n';

    int n,m;
    cin >> n >> m;
    rep(i,0,m) {
        int a,b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int cnt = 0;
    rep(i,1,2*n+1) {
        if (!used[i]) {
            nc = 0;
            f(i);
            cnt += nc % 2;
        }
    }
    cout << cnt / 2 << endl;

    return 0;
}
0