提出 #75064100


ソースコード 拡げる

import queue

N, M = map(int,input().split())
node = [[] for i in range(N)]

for i in range(M):
  a,b = map(int,input().split())
  node[a-1].append(b-1)
  
q = queue.Queue()
can_get = [False for i in range(N)]

count = 1
q.put(0)
can_get[0] = True

while not q.empty():
  t = q.get()
  next = node[t]
  for s in next:
    if not can_get[s]:
      q.put(s)
      can_get[s] = True
      count += 1

print(count)
  

提出情報

提出日時
問題 C - Straw Millionaire
ユーザ YH0
言語 Python (CPython 3.13.7)
得点 300
コード長 439 Byte
結果 AC
実行時間 1044 ms
メモリ 52376 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 22
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 01_handmade_06.txt, 01_handmade_07.txt, 01_handmade_08.txt, 01_handmade_09.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 03_killer_00.txt, 03_killer_01.txt, 03_killer_02.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 15 ms 10044 KiB
00_sample_01.txt AC 16 ms 10140 KiB
00_sample_02.txt AC 15 ms 10040 KiB
01_handmade_00.txt AC 271 ms 12436 KiB
01_handmade_01.txt AC 276 ms 12440 KiB
01_handmade_02.txt AC 286 ms 12476 KiB
01_handmade_03.txt AC 332 ms 18984 KiB
01_handmade_04.txt AC 300 ms 13876 KiB
01_handmade_05.txt AC 1037 ms 52376 KiB
01_handmade_06.txt AC 1044 ms 52376 KiB
01_handmade_07.txt AC 682 ms 35952 KiB
01_handmade_08.txt AC 687 ms 35960 KiB
01_handmade_09.txt AC 313 ms 27632 KiB
02_random_00.txt AC 433 ms 49304 KiB
02_random_01.txt AC 361 ms 23212 KiB
02_random_02.txt AC 218 ms 17776 KiB
02_random_03.txt AC 412 ms 25536 KiB
02_random_04.txt AC 340 ms 22076 KiB
02_random_05.txt AC 306 ms 22400 KiB
03_killer_00.txt AC 665 ms 47608 KiB
03_killer_01.txt AC 653 ms 45152 KiB
03_killer_02.txt AC 667 ms 50056 KiB