結果

問題 No.2202 贅沢てりたまチキン
ユーザー lllllll88938494lllllll88938494
提出日時 2023-03-23 23:31:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,818 ms / 2,000 ms
コード長 673 bytes
コンパイル時間 889 ms
コンパイル使用メモリ 11,808 KB
実行使用メモリ 102,724 KB
最終ジャッジ日時 2023-10-18 19:45:29
合計ジャッジ時間 16,179 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,184 KB
testcase_01 AC 30 ms
10,184 KB
testcase_02 AC 29 ms
10,184 KB
testcase_03 AC 29 ms
10,184 KB
testcase_04 AC 29 ms
10,184 KB
testcase_05 AC 28 ms
10,184 KB
testcase_06 AC 28 ms
10,184 KB
testcase_07 AC 29 ms
10,184 KB
testcase_08 AC 29 ms
10,184 KB
testcase_09 AC 28 ms
10,184 KB
testcase_10 AC 304 ms
41,624 KB
testcase_11 AC 28 ms
10,184 KB
testcase_12 AC 28 ms
10,184 KB
testcase_13 AC 28 ms
10,184 KB
testcase_14 AC 1,104 ms
102,724 KB
testcase_15 AC 1,105 ms
102,724 KB
testcase_16 AC 957 ms
63,312 KB
testcase_17 AC 983 ms
63,312 KB
testcase_18 AC 471 ms
36,788 KB
testcase_19 AC 654 ms
60,292 KB
testcase_20 AC 1,032 ms
66,576 KB
testcase_21 AC 1,014 ms
66,576 KB
testcase_22 AC 724 ms
25,840 KB
testcase_23 AC 928 ms
35,392 KB
testcase_24 AC 844 ms
30,500 KB
testcase_25 AC 1,818 ms
84,720 KB
testcase_26 AC 1,241 ms
102,724 KB
testcase_27 AC 1,123 ms
84,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**6)

n,m = map(int,input().split())
ue=[[] for i in range(n)]
shita=[[] for i in range(n)]
for i in range(m):
    x,y=map(int,input().split())
    x-=1
    y-=1
    ue[x].append(y)
    shita[y].append(x)
    ue[y].append(x)
    shita[x].append(y)


fu = [0]*n
fs = [0]*n
def  cal(x,f):
    if f == 0:
        fu[x] = 1
        for i in ue[x]:
            if fs[i] == 0:
                cal(i,1)
    else:
        fs[x] = 1
        for i in shita[x]:
            if fu[i] == 0:
                cal(i,0)

for i in range(n):
    if fu[i] == 0 and fs[i] == 0:
        cal(i,0)

if all(fu) and all(fs):
    print('Yes')
else:
    print('No')
0