結果

問題 No.2418 情報通だよ!Nafmoくん
ユーザー new_textfilenew_textfile
提出日時 2023-08-12 13:45:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 2,331 bytes
コンパイル時間 2,201 ms
コンパイル使用メモリ 205,716 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-30 03:59:58
合計ジャッジ時間 3,910 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 55 ms
5,376 KB
testcase_04 AC 9 ms
5,376 KB
testcase_05 AC 40 ms
5,376 KB
testcase_06 AC 36 ms
5,376 KB
testcase_07 AC 43 ms
5,376 KB
testcase_08 AC 36 ms
5,376 KB
testcase_09 AC 53 ms
5,376 KB
testcase_10 AC 58 ms
5,376 KB
testcase_11 AC 48 ms
5,376 KB
testcase_12 AC 32 ms
5,376 KB
testcase_13 AC 17 ms
5,376 KB
testcase_14 AC 31 ms
5,376 KB
testcase_15 AC 39 ms
5,376 KB
testcase_16 AC 60 ms
5,376 KB
testcase_17 AC 19 ms
5,376 KB
testcase_18 AC 29 ms
5,376 KB
testcase_19 AC 6 ms
5,376 KB
testcase_20 AC 42 ms
5,376 KB
testcase_21 AC 19 ms
5,376 KB
testcase_22 AC 24 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
// #include <atcoder/all>
// #include <atcoder/modint>
// #include <atcoder/segtree>
// #include <atcoder/lazysegtree>
#include <atcoder/dsu>
// #include <atcoder/scc>
using namespace atcoder;

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")

typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef priority_queue<pll, vpll, function<bool(pll,pll)> > pqpll; 
typedef priority_queue<ll, vll, function<bool(pll,pll)> > pqll;
 
struct edge{ ll to, cost; edge(ll e_to,ll e_cost): to(e_to), cost(e_cost){} };
typedef vector<vector<edge>> Graph;
 
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define LINF (1LL << 60)
#define INF (1 << 30)
#define fs first
#define sc second
#define EPS (ld)1e-10
#define ALL(a) a.begin(), a.end()
#define tcheck(a) if((clock() - start)/(ld)CLOCKS_PER_SEC >= a) break
#define debug(s) cout << #s << endl
#define debugval(x) cout << #x" = " << x << endl
 
template<typename T> ll sz(vector<T> &pos){ return (ll)pos.size(); }
template<typename T> ll sz(priority_queue<T, vector<T> > &que) {return (ll)que.size(); }
template<typename T> ll sz(priority_queue<T, vector<T>, greater<T> > &que) {return (ll)que.size(); }
ll sz(string &s) {return (ll)s.size(); } 
 
template<typename T> void chmin(T &a, T b) { if(a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if(a < b) a = b; }
 
ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b; }
// ll dx[4] = {0,-1,0,1},dy[4] = {-1,0,1,0};
ll dx[8] = {0,-1,-1,-1,0,1,1,1},dy[8] = {-1,-1,0,1,1,1,0,-1};
inline bool isinside(ll i,ll n){ return (i < n && i >= 0); }

int main(){
    ll n,m;
    cin >> n >> m;

    dsu uf(2*n);
    rep(i,0,m){
        ll u,v; cin >> u >> v;
        u--; v--;
        uf.merge(u,v);
    }

    ll ans = 0;
    rep(i,0,2*n){
        if(uf.leader(i) == i){
            ans += uf.size(i) % 2;
        }
    }
    ans /= 2;

    cout << ans << endl;
}
0