結果

問題 No.583 鉄道同好会
ユーザー fiordfiord
提出日時 2017-10-27 23:47:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 1,792 bytes
コンパイル時間 881 ms
コンパイル使用メモリ 104,064 KB
実行使用メモリ 4,536 KB
最終ジャッジ日時 2023-08-14 05:14:58
合計ジャッジ時間 2,082 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 14 ms
4,380 KB
testcase_12 AC 18 ms
4,380 KB
testcase_13 AC 18 ms
4,380 KB
testcase_14 AC 18 ms
4,380 KB
testcase_15 AC 23 ms
4,380 KB
testcase_16 AC 41 ms
4,536 KB
testcase_17 AC 50 ms
4,476 KB
testcase_18 AC 50 ms
4,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <random>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
#define bicnt(x)	__buildin__popcount(x)
#define debug(x)	cout<<"debug: "<<x<<endl
#define DEBUG 0

const ll inf = (ll)1e9;
const ll mod = 998244353;
const ld eps = 1e-9;
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };

vint edge[500];
bool visited[500];
bool used[500];

void dfs(int i) {
	visited[i] = true;
	rep(j, edge[i].size()) {
		int to = edge[i][j];
		if (!visited[to])	dfs(to);
	}
}

int main() {
	int n, m;	cin >> n >> m;
	rep(i, m) {
		int a, b;	cin >> a >> b;
		edge[a].push_back(b);
		edge[b].push_back(a);
		used[a] = used[b] = true;
	}
	rep(i, n)	if (used[i]) {
		dfs(i);
		rep(j, n)	if (used[j] && !visited[j]) {
			cout << "NO" << endl;
			return 0;
		}
		int cnt = 0;
		rep(j, n)	if (edge[j].size() % 2)	cnt++;
		if (cnt <= 2)	cout << "YES" << endl;
		else	cout << "NO" << endl;
		return 0;
	}
}
0