結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,208 KB
testcase_01 AC 29 ms
10,208 KB
testcase_02 AC 28 ms
10,208 KB
testcase_03 AC 28 ms
10,208 KB
testcase_04 AC 28 ms
10,208 KB
testcase_05 AC 28 ms
10,208 KB
testcase_06 AC 29 ms
10,208 KB
testcase_07 AC 29 ms
10,208 KB
testcase_08 AC 28 ms
10,208 KB
testcase_09 AC 28 ms
10,208 KB
testcase_10 AC 291 ms
41,648 KB
testcase_11 AC 28 ms
10,208 KB
testcase_12 AC 28 ms
10,208 KB
testcase_13 AC 28 ms
10,208 KB
testcase_14 AC 1,086 ms
102,768 KB
testcase_15 AC 1,102 ms
102,768 KB
testcase_16 AC 952 ms
63,356 KB
testcase_17 AC 975 ms
63,356 KB
testcase_18 AC 472 ms
36,832 KB
testcase_19 AC 644 ms
60,336 KB
testcase_20 AC 1,006 ms
66,620 KB
testcase_21 AC 1,006 ms
66,620 KB
testcase_22 AC 714 ms
25,884 KB
testcase_23 AC 906 ms
35,436 KB
testcase_24 AC 809 ms
30,544 KB
testcase_25 AC 1,776 ms
84,764 KB
testcase_26 AC 1,232 ms
102,768 KB
testcase_27 AC 1,087 ms
84,736 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