結果

問題 No.408 五輪ピック
コンテスト
ユーザー YuuuT
提出日時 2026-11-23 16:08:17
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
MLE  
実行時間 -
コード長 1,410 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 86 ms
コンパイル使用メモリ 64,240 KB
実行使用メモリ 93,488 KB
最終ジャッジ日時 2026-11-23 16:08:49
合計ジャッジ時間 31,998 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 MLE * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# library: https://github.com/yu-0811/competitive-programming-library
import sys,math;
# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')
from collections import defaultdict,deque
from itertools import combinations,permutations,accumulate,product
from bisect import bisect_left,bisect_right
from heapq import heappop,heappush,heapify
#from more_itertools import distinct_permutations,distinct_combinations
def input():return sys.stdin.readline().rstrip()
def ii(): return int(input())
def ms(): return map(int, input().split())
def li(): return list(map(int,input().split()))
inf = pow(10,18)
mod = 998244353
#//////////////////////////
N,M = ms()
G = [[] for i in range(N)]
for i in range(M):
    a,b = ms()
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

def solve(C,K):
    # https://info.atcoder.jp/entry/algorithm_lectures/color_coding
    # 問題2の解法
    dp = [False]*N
    dp[0] = True

    for i in range(1,K):
        nx = [False]*N
        for v in range(N):
            if C[v] != i: continue
            for u in G[v]:
                if dp[u]:
                    nx[v] = True
        dp = nx[:]
    
    for u in G[0]:
        if dp[u]:
            return True
    
    return False

from random import randint
C = [0]*N
for _ in range(1000):
    for i in range(1,N):
        C[i] = randint(1,4)
    if solve(C,5):
        print("YES")
        exit()

print("NO")
0