結果

問題 No.583 鉄道同好会
ユーザー WA_TLEWA_TLE
提出日時 2017-10-27 22:30:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 1,686 bytes
コンパイル時間 1,407 ms
コンパイル使用メモリ 138,500 KB
実行使用メモリ 5,632 KB
最終ジャッジ日時 2024-05-01 17:06:44
合計ジャッジ時間 2,620 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 14 ms
5,376 KB
testcase_12 AC 19 ms
5,376 KB
testcase_13 AC 19 ms
5,376 KB
testcase_14 AC 19 ms
5,376 KB
testcase_15 AC 23 ms
5,376 KB
testcase_16 AC 43 ms
5,376 KB
testcase_17 AC 56 ms
5,632 KB
testcase_18 AC 55 ms
5,504 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/c++allocator.h:33,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/allocator.h:46,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/deque:61,
                 from main.cpp:1:
In member function '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 /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/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 /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/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 /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_queue.h:286:20,
    inlined from 'int main()' at main.cpp:56:10:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/new_allocator.h:175:11: warning: 't' may be used uninitialized [-Wmaybe-uninitialized]
  175 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp: In function 'int main()':
main.cpp:49:13: note: 't' was declared here
   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