結果

問題 No.408 五輪ピック
ユーザー chocoruskchocorusk
提出日時 2018-11-03 10:32:26
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 185 ms / 5,000 ms
コード長 1,243 bytes
コンパイル時間 868 ms
コンパイル使用メモリ 96,716 KB
実行使用メモリ 54,380 KB
最終ジャッジ日時 2023-08-13 02:08:02
合計ジャッジ時間 4,156 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
52,672 KB
testcase_01 AC 14 ms
52,680 KB
testcase_02 AC 16 ms
52,828 KB
testcase_03 AC 15 ms
52,672 KB
testcase_04 AC 16 ms
52,704 KB
testcase_05 AC 36 ms
53,608 KB
testcase_06 AC 91 ms
53,704 KB
testcase_07 AC 97 ms
53,852 KB
testcase_08 AC 31 ms
53,460 KB
testcase_09 AC 36 ms
53,540 KB
testcase_10 AC 93 ms
53,400 KB
testcase_11 AC 87 ms
53,652 KB
testcase_12 AC 108 ms
53,856 KB
testcase_13 AC 35 ms
53,792 KB
testcase_14 AC 39 ms
53,156 KB
testcase_15 AC 35 ms
53,692 KB
testcase_16 AC 38 ms
53,700 KB
testcase_17 AC 40 ms
53,784 KB
testcase_18 AC 44 ms
53,908 KB
testcase_19 AC 61 ms
54,000 KB
testcase_20 AC 54 ms
53,224 KB
testcase_21 AC 36 ms
53,516 KB
testcase_22 AC 81 ms
53,472 KB
testcase_23 AC 44 ms
54,072 KB
testcase_24 AC 72 ms
53,700 KB
testcase_25 AC 65 ms
53,792 KB
testcase_26 AC 185 ms
54,380 KB
testcase_27 AC 143 ms
53,924 KB
testcase_28 AC 35 ms
53,384 KB
testcase_29 AC 43 ms
53,528 KB
testcase_30 AC 15 ms
52,772 KB
testcase_31 AC 15 ms
52,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, m;
	cin>>n>>m;
	int a[50000], b[50000];
	vector<int> g[20000];
	for(int i=0; i<m; i++){
		cin>>a[i]>>b[i];
		a[i]--; b[i]--;
		g[a[i]].push_back(b[i]);
		g[b[i]].push_back(a[i]);
	}
	bitset<20000> bs[20000];
	for(auto p:g[0]){
		for(auto y:g[p]){
			if(y==0) continue;
			bs[y][p]=1;
		}
	}
	for(int i=0; i<m; i++){
		if(a[i]==0 || b[i]==0) continue;
		bool nuo1=0, nuo2=0;
		if(bs[a[i]][b[i]]) nuo1=1, bs[a[i]][b[i]]=0;
		if(bs[b[i]][a[i]]) nuo2=1, bs[b[i]][a[i]]=0;
		int c1=bs[a[i]].count(), c2=bs[b[i]].count();
		if(c1==0 || c2==0){
			if(nuo1) bs[a[i]][b[i]]=1;
			if(nuo2) bs[b[i]][a[i]]=1;
			continue;
		}
		if(c1>=2 || c2>=2){
			cout<<"YES"<<endl;
			return 0;
		}
		if((bs[a[i]]&bs[b[i]]).count()==0){
			cout<<"YES"<<endl;
			return 0;
		}
		if(nuo1) bs[a[i]][b[i]]=1;
		if(nuo2) bs[b[i]][a[i]]=1;
	}
	cout<<"NO"<<endl;
    return 0;
}
0