結果
問題 | No.2418 情報通だよ!Nafmoくん |
ユーザー | hanba-gu1 |
提出日時 | 2023-08-12 15:15:55 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 184 ms / 2,000 ms |
コード長 | 1,358 bytes |
コンパイル時間 | 4,954 ms |
コンパイル使用メモリ | 275,248 KB |
実行使用メモリ | 43,836 KB |
最終ジャッジ日時 | 2024-04-30 08:40:30 |
合計ジャッジ時間 | 7,632 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 153 ms
37,236 KB |
testcase_04 | AC | 43 ms
34,492 KB |
testcase_05 | AC | 114 ms
19,132 KB |
testcase_06 | AC | 104 ms
31,760 KB |
testcase_07 | AC | 125 ms
18,684 KB |
testcase_08 | AC | 112 ms
43,836 KB |
testcase_09 | AC | 158 ms
24,596 KB |
testcase_10 | AC | 157 ms
35,600 KB |
testcase_11 | AC | 132 ms
32,656 KB |
testcase_12 | AC | 92 ms
27,532 KB |
testcase_13 | AC | 42 ms
12,068 KB |
testcase_14 | AC | 80 ms
20,252 KB |
testcase_15 | AC | 91 ms
11,432 KB |
testcase_16 | AC | 184 ms
30,408 KB |
testcase_17 | AC | 42 ms
8,704 KB |
testcase_18 | AC | 83 ms
27,984 KB |
testcase_19 | AC | 32 ms
23,876 KB |
testcase_20 | AC | 105 ms
12,288 KB |
testcase_21 | AC | 50 ms
16,312 KB |
testcase_22 | AC | 57 ms
10,880 KB |
ソースコード
#include<bits/stdc++.h> #include<atcoder/all> using namespace std; using namespace atcoder; using ll = int_fast64_t; using ull = uint_fast64_t; using mint = modint998244353; constexpr ll INF = 1ll << 60; #define iscontain(container, value) (find(container.begin(), container.end(), value) != container.end()) template<typename T, typename D> void printelem(const T& container, const D& divide){ for(const auto& i : container) cout << i << divide; cout << endl; } template<typename T> void printelem(const T& container) { printelem(container, ", "); } template<typename T> T input() { T ret; cin >> ret; return ret; } ll N, M; vector<set<ll>> mate; vector<ll> group; vector<set<ll>> member; vector<ll> belong; void make_group(ll p, ll g){ for(auto&& i : mate[p]){ if(belong[i] != -1) continue; belong[i] = g; member[g].insert(i); group[g]++; make_group(i, g); } } int main(){ //インプット cin >> N >> M; mate.resize(N*2); for(ll i = 0; i < M; i++){ ll A, B; cin >> A >> B, A--, B--; mate[A].insert(B); mate[B].insert(A); } belong.resize(N*2, -1); for(ll i = 0; i < N*2; i++){ if(belong[i] == -1){ belong[i] = group.size(); group.push_back(1); member.push_back({i}); make_group(i, belong[i]); } } ll ans = 0; for(auto&& i : group) ans += i % 2; //アウトプット cout << ans/2; return 0; }