結果

問題 No.583 鉄道同好会
ユーザー newlife171128newlife171128
提出日時 2018-01-21 08:08:43
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 1,116 bytes
コンパイル時間 2,556 ms
コンパイル使用メモリ 146,388 KB
実行使用メモリ 4,628 KB
最終ジャッジ日時 2023-08-26 18:17:04
合計ジャッジ時間 4,670 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 12 ms
4,376 KB
testcase_12 AC 17 ms
4,376 KB
testcase_13 AC 16 ms
4,380 KB
testcase_14 AC 17 ms
4,376 KB
testcase_15 AC 21 ms
4,380 KB
testcase_16 AC 39 ms
4,528 KB
testcase_17 AC 45 ms
4,628 KB
testcase_18 AC 44 ms
4,480 KB
権限があれば一括ダウンロードができます

ソースコード

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