提出 #17717380


ソースコード 拡げる

from sys import stdin
input = stdin.readline
from sys import setrecursionlimit
setrecursionlimit(100010)
def helper(curr):
    currA, currB = 0, 0
    for i in curr:
        taken.add(i)
        currA += a[i-1]
        currB += b[i-1]
    temp = []
    for i in curr:
        for j in adj[i]:
            if j not in taken:
                temp.append(j)
    
    if temp:
        call = helper(temp)
        currA, currB = currA + call[0], currB + call[1]
    return currA, currB
        
from collections import defaultdict
n, m  =    map(int, input().split())
a     =    list(map(int, input().split()))
b     =    list(map(int, input().split()))
adj   =    defaultdict(set)

for _ in range(m):
    c, d = map(int, input().split())
    adj[c].add(d)
    adj[d].add(c)

    
taken = set()
for i in range(1, n+1):
    if i not in taken:
        sa, sb = helper([i])
        if sa!=sb:
            print('No')
            break
else:
    print('Yes')

提出情報

提出日時
問題 B - Values
ユーザ coder1033
言語 PyPy3 (7.3.0)
得点 0
コード長 990 Byte
結果 WA
実行時間 507 ms
メモリ 180704 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 400
結果
AC × 4
AC × 35
WA × 9
セット名 テストケース
Sample 00_sample_00, 00_sample_01, 00_sample_02, 00_sample_03
All 00_sample_00, 00_sample_01, 00_sample_02, 00_sample_03, 01_small_0, 01_small_1, 01_small_2, 01_small_3, 01_small_4, 01_small_5, 01_small_6, 01_small_7, 01_small_8, 01_small_9, 02_large_0, 02_large_1, 02_largecon_0, 02_largecon_1, 02_largecon_2, 02_largecon_3, 02_largecon_4, 02_largecon_5, 02_toolarge_0, 02_toolarge_1, 02_toolarge_2, 02_toolarge_3, 03_few_e_0, 03_few_e_1, 03_few_e_2, 03_few_e_3, 03_few_e_4, 03_few_e_5, 03_is_tree_0, 03_is_tree_1, 03_is_tree_2, 03_is_tree_3, 04_kill_overflow_0, 04_kill_overflow_1, 04_kill_overflow_2, 04_kill_overflow_3, 04_sumequal_0, 04_sumequal_1, 04_sumequal_2, 04_sumequal_3
ケース名 結果 実行時間 メモリ
00_sample_00 AC 82 ms 64792 KiB
00_sample_01 AC 59 ms 64876 KiB
00_sample_02 AC 60 ms 64836 KiB
00_sample_03 AC 58 ms 65020 KiB
01_small_0 AC 59 ms 64760 KiB
01_small_1 AC 57 ms 64976 KiB
01_small_2 AC 56 ms 64960 KiB
01_small_3 AC 57 ms 64988 KiB
01_small_4 AC 57 ms 64996 KiB
01_small_5 AC 60 ms 64996 KiB
01_small_6 AC 59 ms 64676 KiB
01_small_7 WA 57 ms 64796 KiB
01_small_8 AC 58 ms 64856 KiB
01_small_9 AC 58 ms 64644 KiB
02_large_0 WA 244 ms 121048 KiB
02_large_1 WA 192 ms 93468 KiB
02_largecon_0 WA 489 ms 157544 KiB
02_largecon_1 WA 454 ms 166244 KiB
02_largecon_2 AC 486 ms 156612 KiB
02_largecon_3 AC 357 ms 135024 KiB
02_largecon_4 AC 507 ms 180704 KiB
02_largecon_5 WA 495 ms 149392 KiB
02_toolarge_0 AC 378 ms 162080 KiB
02_toolarge_1 WA 467 ms 171244 KiB
02_toolarge_2 AC 335 ms 155812 KiB
02_toolarge_3 AC 374 ms 162412 KiB
03_few_e_0 AC 156 ms 115268 KiB
03_few_e_1 AC 131 ms 105344 KiB
03_few_e_2 AC 118 ms 96856 KiB
03_few_e_3 AC 196 ms 140824 KiB
03_few_e_4 AC 136 ms 106224 KiB
03_few_e_5 AC 122 ms 99580 KiB
03_is_tree_0 AC 282 ms 128268 KiB
03_is_tree_1 WA 334 ms 132468 KiB
03_is_tree_2 AC 302 ms 127580 KiB
03_is_tree_3 WA 314 ms 129884 KiB
04_kill_overflow_0 AC 499 ms 165844 KiB
04_kill_overflow_1 AC 403 ms 134196 KiB
04_kill_overflow_2 AC 468 ms 142472 KiB
04_kill_overflow_3 AC 392 ms 130464 KiB
04_sumequal_0 AC 161 ms 107496 KiB
04_sumequal_1 AC 141 ms 89028 KiB
04_sumequal_2 AC 93 ms 75908 KiB
04_sumequal_3 AC 121 ms 89244 KiB