結果
| 問題 | No.1465 Archaea |
| コンテスト | |
| ユーザー |
hiraku
|
| 提出日時 | 2021-04-03 09:49:36 |
| 言語 | Python3 (3.14.2 + numpy 2.4.0 + scipy 1.16.3) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 942 bytes |
| 記録 | |
| コンパイル時間 | 428 ms |
| コンパイル使用メモリ | 12,288 KB |
| 実行使用メモリ | 45,312 KB |
| 最終ジャッジ日時 | 2024-12-24 12:36:00 |
| 合計ジャッジ時間 | 3,797 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 17 RE * 3 |
ソースコード
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):
graph[i].append(i + 3)
graph[i].append(i * 2)
bfs(1, n)
ans = visited[n]
if ans == INF or ans > k:
print("NO")
else:
print("YES")
hiraku