結果

問題 No.1465 Archaea
ユーザー hirakuhiraku
提出日時 2021-04-03 09:51:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 988 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 11,000 KB
実行使用メモリ 40,100 KB
最終ジャッジ日時 2023-08-26 00:21:28
合計ジャッジ時間 3,020 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,720 KB
testcase_01 AC 19 ms
8,524 KB
testcase_02 AC 19 ms
8,744 KB
testcase_03 AC 19 ms
8,540 KB
testcase_04 WA -
testcase_05 AC 18 ms
8,664 KB
testcase_06 AC 18 ms
8,612 KB
testcase_07 AC 65 ms
16,236 KB
testcase_08 AC 19 ms
8,556 KB
testcase_09 AC 94 ms
20,268 KB
testcase_10 AC 18 ms
8,576 KB
testcase_11 AC 83 ms
18,196 KB
testcase_12 AC 20 ms
8,924 KB
testcase_13 AC 190 ms
32,528 KB
testcase_14 AC 81 ms
18,632 KB
testcase_15 AC 19 ms
8,708 KB
testcase_16 AC 21 ms
8,936 KB
testcase_17 AC 189 ms
33,660 KB
testcase_18 AC 28 ms
10,392 KB
testcase_19 AC 93 ms
19,740 KB
testcase_20 AC 149 ms
27,132 KB
testcase_21 AC 246 ms
40,100 KB
testcase_22 AC 248 ms
40,064 KB
testcase_23 AC 18 ms
8,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque


def bfs(start, goal):
    """[summary]
    dfs: stack, pop()
    bfs: queue, popleft()

    Parameters
    ----------
    start : [int]
        [description]
    goal : [int]
        [description]
    """
    queue = deque()
    for i in graph[start]:
        queue.append((i))
        visited[i] = 1
    while queue:
        q = queue.popleft()
        # ゴールの条件(無くても良い)
        # if q == goal and d == 0:
        #   return
        dist = visited[q]
        for i in graph[q]:
            if i <= n and visited[i] > dist + 1:
                queue.append((i))
                visited[i] = dist + 1


n, k = map(int, input().split())
graph = [list() for _ in range(n + 1)]
INF = 10 ** 9
visited = [INF] * (n + 1)
for i in range(1, n + 1):
    if i + 3 <= n:
        graph[i].append(i + 3)
    if i * 2 <= n:
        graph[i].append(i * 2)

bfs(1, n)
ans = visited[n]
if ans == INF or ans > k:
    print("NO")
else:
    print("YES")
0