結果

問題 No.2403 "Eight" Bridges of Königsberg
ユーザー MagentorMagentor
提出日時 2023-08-04 21:54:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,294 bytes
コンパイル時間 4,498 ms
コンパイル使用メモリ 260,492 KB
実行使用メモリ 13,696 KB
最終ジャッジ日時 2024-04-22 20:13:03
合計ジャッジ時間 6,117 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 40 ms
5,376 KB
testcase_05 AC 78 ms
5,376 KB
testcase_06 AC 86 ms
5,376 KB
testcase_07 AC 51 ms
5,376 KB
testcase_08 AC 61 ms
5,376 KB
testcase_09 AC 92 ms
5,376 KB
testcase_10 AC 86 ms
5,376 KB
testcase_11 AC 66 ms
5,376 KB
testcase_12 AC 94 ms
5,376 KB
testcase_13 AC 64 ms
5,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 46 ms
13,696 KB
testcase_20 AC 8 ms
5,520 KB
testcase_21 AC 20 ms
8,576 KB
testcase_22 AC 38 ms
12,672 KB
testcase_23 AC 37 ms
12,288 KB
testcase_24 AC 22 ms
10,624 KB
testcase_25 AC 27 ms
10,240 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 24 ms
10,880 KB
testcase_29 WA -
testcase_30 AC 12 ms
7,296 KB
testcase_31 AC 31 ms
13,184 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep2(i, m ,n) for (int i = (m); i < (long long)(n); i++)
#define REP(i, n) for (long long i = 1; i < (long long)(n); i++)
typedef long long ll;
#define updiv(N,X) (N + X - 1) / X
#define l(n) n.begin(),n.end()
#define YesNo(Q) Q==1?cout<<"Yes":cout<<"No"
using P = pair<int, int>;
using mint = modint;
const int MOD = 998244353LL;
const ll INF = 999999999999LL;
vector<long long> fact, fact_inv, inv;
/*  init_nCk :二項係数のための前処理
    計算量:O(n)
*/
template <typename T>
void input(vector<T> &v){
 rep(i,v.size()){cin>>v[i];}
  return;
}
void init_nCk(int SIZE) {
    fact.resize(SIZE + 5);
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
}
/*  nCk :MODでの二項係数を求める(前処理 int_nCk が必要)
    計算量:O(1)
*/
long long nCk(int n, int k) {
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    return fact[n] * (fact_inv[k] * fact_inv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll POW(ll a,ll n){
  long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}
int main() {
 int n,m;cin>>n>>m;
 dsu d(n);
 vector<ll> v(n);vector<int> w(n);
 rep(i,m){int a,b;cin>>a>>b;a--;b--;d.merge(a,b);v[a]++;w[b]++;}
 ll sm = 0;
 rep(i,n){sm += abs(v[i]-w[i]);}
 sm /= 2;
 sm = max(0LL,sm-1);//cout<<sm<<endl;
 set<int> st;rep(i,n){st.insert(d.leader(i));}
 //cout << st.size();
 cout << sm << endl;
 //cout << max(sm,(ll)(st.size())-1) << endl;
}
0