結果

問題 No.583 鉄道同好会
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2016-12-07 02:53:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 1,307 bytes
コンパイル時間 706 ms
コンパイル使用メモリ 86,640 KB
実行使用メモリ 6,048 KB
最終ジャッジ日時 2023-09-08 15:06:09
合計ジャッジ時間 2,454 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,924 KB
testcase_01 AC 3 ms
5,700 KB
testcase_02 AC 3 ms
5,800 KB
testcase_03 AC 3 ms
5,792 KB
testcase_04 AC 4 ms
6,004 KB
testcase_05 AC 4 ms
5,740 KB
testcase_06 AC 3 ms
5,792 KB
testcase_07 AC 4 ms
5,804 KB
testcase_08 AC 3 ms
5,696 KB
testcase_09 AC 4 ms
5,800 KB
testcase_10 AC 3 ms
5,720 KB
testcase_11 AC 17 ms
6,048 KB
testcase_12 AC 21 ms
5,744 KB
testcase_13 AC 23 ms
5,824 KB
testcase_14 AC 21 ms
5,748 KB
testcase_15 AC 26 ms
5,752 KB
testcase_16 AC 45 ms
5,828 KB
testcase_17 AC 53 ms
5,936 KB
testcase_18 AC 52 ms
5,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll n;
ll flag[555];
ll d[555][555];
ll dd[555];

void dfs(ll p){
	flag[p] = 1;
	rep(i,0,n){
		if(d[p][i]==0)continue;
		if(flag[i]==1)continue;
		dfs(i);
	}
}

int main() {
	ll m;
	cin>>n>>m;
	ll mn = 1000;
	clr(flag,-1);
	clr(d,0);
	clr(dd,0);
	rep(i,0,m){
		ll a,b;
		cin>>a>>b;
		flag[a] = 0;
		flag[b] = 0;
		d[a][b] = 1;
		d[b][a] = 1;
		dd[a]++;
		dd[b]++;
		mn = min(mn,a);
	}
	dfs(mn);
	rep(i,0,n){
		if(flag[i]==0){
			cout << "NO" << endl;
			return 0;
		}
	}
	ll odd = 0;
	rep(i,0,n){
		if(dd[i]%2==1)odd++;
	}
	if(odd>2)cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}
0