結果

問題 No.2403 "Eight" Bridges of Königsberg
ユーザー monnu
提出日時 2023-08-04 21:53:58
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 528 bytes
コンパイル時間 1,624 ms
コンパイル使用メモリ 168,336 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-14 19:51:21
合計ジャッジ時間 3,216 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> u(M), v(M);
    vector<int> inDegree(N, 0);
    vector<int> outDegree(N, 0);
    for (int i = 0; i < M; i++)
    {
        cin >> u[i] >> v[i];
        u[i]--;
        v[i]--;
        inDegree[v[i]]++;
        outDegree[u[i]]++;
    }

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans += abs(inDegree[i] - outDegree[i]);
    }
    ans /= 2;
    cout << max(0, ans - 1) << endl;
}
0