結果

問題 No.583 鉄道同好会
ユーザー WA_TLEWA_TLE
提出日時 2017-10-27 22:30:11
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 1,686 bytes
コンパイル時間 1,405 ms
コンパイル使用メモリ 137,740 KB
実行使用メモリ 5,552 KB
最終ジャッジ日時 2023-08-14 04:18:26
合計ジャッジ時間 2,626 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 14 ms
4,380 KB
testcase_12 AC 19 ms
4,380 KB
testcase_13 AC 18 ms
4,380 KB
testcase_14 AC 19 ms
4,388 KB
testcase_15 AC 23 ms
4,380 KB
testcase_16 AC 43 ms
4,932 KB
testcase_17 AC 51 ms
5,552 KB
testcase_18 AC 51 ms
5,396 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
次のファイルから読み込み:  /usr/local/gcc7/include/c++/12.2.0/x86_64-pc-linux-gnu/bits/c++allocator.h:33,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/bits/allocator.h:46,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/deque:61,
         次から読み込み:  main.cpp:1:
メンバ関数 ‘void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = int; _Args = {const int&}; _Tp = int]’ 内,
    inlined from ‘static void std::allocator_traits<std::allocator<_Tp1> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = int; _Args = {const int&}; _Tp = int]’ at /usr/local/gcc7/include/c++/12.2.0/bits/alloc_traits.h:516:17,
    inlined from ‘void std::deque<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>]’ at /usr/local/gcc7/include/c++/12.2.0/bits/stl_deque.h:1543:30,
    inlined from ‘void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >]’ at /usr/local/gcc7/include/c++/12.2.0/bits/stl_queue.h:286:20,
    inlined from ‘int main()’ at main.cpp:56:10:
/usr/local/gcc7/include/c++/12.2.0/bits/new_allocator.h:175:11: 警告: ‘t’ may be used uninitialized [-Wmaybe-uninitialized]
  175 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp: 関数 ‘int main()’ 内:
main.cpp:49:13: 備考: ‘t’ はここで定義されています
   49 |         int t;
      |             ^

ソースコード

diff #

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<-1<<endl;return 0
//ios::sync_with_stdio(false);
//<< setprecision(5)
const int mod=1e9+7;
const int big=1e8+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	int i,j,n,m;
	cin>>n>>m;
	vector<vector<int>>go(n);
	int t;
	for(i=0;i<m;i++){
		int a,b;cin>>a>>b;
		go[a].pub(b);
		go[b].pub(a);t=a;
	}
	queue<int>que;//連結
	que.push(t);//適当
	vector<bool>can(n);
	while(!que.empty()){
		int ter=que.front();
		que.pop();
		if(can[ter]){continue;}
		can[ter]=true;
		for(auto it:go[ter]){que.push(it);}
	}
	int ki=0;
	for(i=0;i<n;i++){
		if(go[i].size()>0&&(!can[i])){cout<<"NO"<<endl;return 0;}
		ki+=go[i].size()%2;
	}
	if(ki<=2){cout<<"YES"<<endl;}
	else{cout<<"NO"<<endl;}
	return 0;
}
0