結果

問題 No.583 鉄道同好会
ユーザー newlife171128
提出日時 2018-01-21 08:08:43
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 1,116 bytes
コンパイル時間 3,149 ms
コンパイル使用メモリ 160,472 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-25 18:15:31
合計ジャッジ時間 3,544 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <map>
#include <string.h>
#include <utility>

typedef long long ll;
using namespace std;

typedef pair<int, int> P;

int degree[501];

bool station_point[501];

vector<int> G[501];

void dfs(int a){
	station_point[a] =false;

	for(int i=0; i<G[a].size(); i++){
		if(station_point[G[a][i]]){
			station_point[G[a][i]] =false;
			dfs(G[a][i]);
		}

	}
}

int main() {

	int n=0,m=0;
	cin>>n>>m;

/*	memset(station_point,-1, sizeof(station_point));*/
	int a ,b;
	for(int i=0; i<m; i++){
		cin>>a>>b;

		degree[a]++; degree[b]++;

		station_point[a] =true; station_point[b] =true;

		G[a].push_back(b); G[b].push_back(a);
	}

	dfs(a);
	for(int i=0; i<n; i++){
		if(station_point[i]){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	int cp=0;

	for(int i=0; i<n; i++){
		if(degree[i] %2 ==1)cp++;
	}

	if(cp ==0 || cp==2){
		cout<<"YES"<<endl;
	}else {
		cout<<"NO"<<endl;
	}

	return 0;
}
0