結果

問題 No.408 五輪ピック
ユーザー chocoruskchocorusk
提出日時 2018-11-03 10:27:01
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,000 bytes
コンパイル時間 1,062 ms
コンパイル使用メモリ 99,700 KB
実行使用メモリ 54,272 KB
最終ジャッジ日時 2024-04-30 20:39:35
合計ジャッジ時間 5,337 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,120 KB
testcase_01 AC 42 ms
52,992 KB
testcase_02 AC 42 ms
53,248 KB
testcase_03 AC 41 ms
52,992 KB
testcase_04 AC 40 ms
53,248 KB
testcase_05 AC 63 ms
53,504 KB
testcase_06 AC 126 ms
53,632 KB
testcase_07 AC 132 ms
53,760 KB
testcase_08 AC 60 ms
53,760 KB
testcase_09 AC 63 ms
53,504 KB
testcase_10 AC 127 ms
53,632 KB
testcase_11 AC 122 ms
53,760 KB
testcase_12 AC 144 ms
54,016 KB
testcase_13 AC 63 ms
53,888 KB
testcase_14 AC 69 ms
53,248 KB
testcase_15 AC 63 ms
53,760 KB
testcase_16 AC 71 ms
53,632 KB
testcase_17 AC 69 ms
53,888 KB
testcase_18 AC 75 ms
53,888 KB
testcase_19 AC 91 ms
54,144 KB
testcase_20 AC 86 ms
53,504 KB
testcase_21 AC 65 ms
53,376 KB
testcase_22 AC 117 ms
53,632 KB
testcase_23 AC 73 ms
54,144 KB
testcase_24 WA -
testcase_25 AC 99 ms
53,760 KB
testcase_26 AC 231 ms
54,272 KB
testcase_27 AC 193 ms
54,016 KB
testcase_28 AC 61 ms
53,760 KB
testcase_29 AC 68 ms
53,632 KB
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

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;
		int c1=bs[a[i]].count(), c2=bs[b[i]].count();
		if(c1==0 || c2==0) 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;
		}
	}
	cout<<"NO"<<endl;
    return 0;
}
0