結果
| 問題 |
No.583 鉄道同好会
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-03-24 18:43:43 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,553 bytes |
| コンパイル時間 | 658 ms |
| コンパイル使用メモリ | 63,840 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-25 03:14:25 |
| 合計ジャッジ時間 | 2,153 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 WA * 1 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
int station;
int strain;
int start, end;
vector<int> stationflag;
vector<int> startArray;
vector<int> endArray;
bool startendflag = false;
int odd=0;
int even=0;
int max;
int min;
int vectMax, vectMin;
cin>>station>>strain;
stationflag.resize(station);
startArray.resize(strain);
endArray.resize(strain);
max=0;
min=station-1;
for(int i=0; i<strain; ++i)
{
cin>>start>>end;
stationflag[start]++;
stationflag[end]++;
*(startArray.data()+i)=start;
*(endArray.data()+i)=end;
if(min>start && max<end)
{
min=start;
max=end;
}
}
vectMin = *min_element(startArray.begin(), startArray.end());
vectMax = *max_element(endArray.begin(), endArray.end());
if(vectMin == min && vectMax == max)
startendflag = true;
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)
{
if(startendflag)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
else
cout<<"NO"<<endl;
}
else
{
if(odd==2 || odd==0)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}