結果

問題 No.2403 "Eight" Bridges of Königsberg
コンテスト
ユーザー 憩いの場
提出日時 2023-08-09 22:15:40
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 552 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 708 ms
コンパイル使用メモリ 80,512 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-10 19:57:26
合計ジャッジ時間 3,491 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<iostream>
#include<vector>

using namespace std;

int main( void )
{
    int N, M;
    cin >> N >> M;
    vector<int> in( N + 1, 0 ), out( N + 1, 0 );
    
    int u, v;
    for( int i = 0; i < M; i++ )
    {
        cin >> u >> v;
        if( u == v ) continue;
        in[v]++, out[u]++;
    }

    int num = 0;
    for( int i = 1; i <= N; i++ )
    {
        num += abs( in[i] - out[i] );
    }

    if( num == 0 || num == 2 )
    {
        cout << 0 << endl;
    }
    else
    {
        cout << num / 2 - 1 << endl;
    }

    return 0;
}
0