結果

問題 No.583 鉄道同好会
ユーザー jiang0503
提出日時 2018-03-24 17:54:52
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,054 bytes
コンパイル時間 538 ms
コンパイル使用メモリ 60,408 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-25 03:11:05
合計ジャッジ時間 1,523 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;

int main(){

    int station;
    int strain;
    int start, end;
    vector<int> stationflag;
    int odd=0;
    int even=0;

    cin>>station>>strain;
    stationflag.resize(station);

    for(int i=0; i<strain; ++i)
    {
        cin>>start>>end;
        stationflag[start]++;
        stationflag[end]++;
    }

    for(int i=0; i<station; ++i)
    {
        if(stationflag[i] % 2 == 0)
            even++;
        else
            odd++;
    }

    if(station%2==0)
    {
        if(odd==2)
            cout<<"YES"<<endl;
        else if(odd==0)
        {
            for(int i=0; i<station; ++i)
            {
                if(stationflag[i]==0)
                {
                    cout<<"NO"<<endl;
                    return 0;
                }
            }
            cout<<"YES"<<endl;
        }

        else
            cout<<"NO"<<endl;
    }
    else
    {
        if(odd==2)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }


    return 0;
}
0