提出 #43199990


ソースコード 拡げる

from collections import defaultdict

N, Q = map(int, input().split())

edge = defaultdict(set)
ans = N

for _ in range(Q):
  type, *args = map(int, input().split())
  if type == 1:
    u, v = args
    for x in [u, v]:
      if not edge[x]: 
        ans -= 1
    edge[u].add(v)
    edge[v].add(u)
    print(ans)
  else:
    v = args[0]
    for x in edge[v]:
      edge[x].remove(v)
      if not edge[x]:
        ans += 1
    if edge[v]:
      edge[v] = set()
      ans += 1
    print(ans)

提出情報

提出日時
問題 E - Isolation
ユーザ arakaki_tokyo
言語 Python (3.8.2)
得点 0
コード長 513 Byte
結果 TLE
実行時間 2126 ms
メモリ 113220 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 425
結果
AC × 2
AC × 34
TLE × 1
セット名 テストケース
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt
ケース名 結果 実行時間 メモリ
example_00.txt AC 30 ms 9040 KiB
example_01.txt AC 21 ms 9036 KiB
hand_00.txt TLE 2126 ms 113220 KiB
hand_01.txt AC 1646 ms 61212 KiB
hand_02.txt AC 1731 ms 60972 KiB
hand_03.txt AC 1493 ms 9172 KiB
hand_04.txt AC 1303 ms 9248 KiB
hand_05.txt AC 1645 ms 56992 KiB
hand_06.txt AC 1688 ms 60968 KiB
hand_07.txt AC 1862 ms 60972 KiB
random_00.txt AC 803 ms 9276 KiB
random_01.txt AC 1393 ms 9312 KiB
random_02.txt AC 335 ms 9248 KiB
random_03.txt AC 895 ms 13268 KiB
random_04.txt AC 1561 ms 9844 KiB
random_05.txt AC 1090 ms 50040 KiB
random_06.txt AC 1182 ms 37808 KiB
random_07.txt AC 1577 ms 10572 KiB
random_08.txt AC 1558 ms 47700 KiB
random_09.txt AC 1523 ms 47648 KiB
random_10.txt AC 677 ms 9948 KiB
random_11.txt AC 962 ms 16060 KiB
random_12.txt AC 715 ms 9384 KiB
random_13.txt AC 684 ms 14000 KiB
random_14.txt AC 1487 ms 32704 KiB
random_15.txt AC 733 ms 11048 KiB
random_16.txt AC 1142 ms 26500 KiB
random_17.txt AC 1589 ms 35696 KiB
random_18.txt AC 869 ms 16416 KiB
random_19.txt AC 1402 ms 61160 KiB
random_20.txt AC 1588 ms 40452 KiB
random_21.txt AC 1054 ms 23300 KiB
random_22.txt AC 1748 ms 66424 KiB
random_23.txt AC 1786 ms 95308 KiB
random_24.txt AC 1433 ms 85192 KiB