結果
| 問題 |
No.467 隠されていたゲーム
|
| コンテスト | |
| ユーザー |
leno
|
| 提出日時 | 2017-09-05 08:53:58 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 933 bytes |
| コンパイル時間 | 353 ms |
| コンパイル使用メモリ | 12,928 KB |
| 実行使用メモリ | 28,384 KB |
| 最終ジャッジ日時 | 2024-11-06 21:48:40 |
| 合計ジャッジ時間 | 6,782 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | TLE * 1 -- * 2 |
| other | -- * 24 |
ソースコード
def chevyshev(x):
ans = []
for i in range(2*x+1):
for j in range(2*x+1):
if max(abs(i-x), abs(j-x)) == x:
ans.append([i-x, j-x])
return ans
def bfs(list, x, y):
queue = [[0, 0]]
visited = []
cnt = 0
while queue:
stack = queue[:]
queue.clear()
while stack:
label = stack.pop(0)
if (label[0] == x) and (label[1] == y):
return cnt
if label in visited:
continue
visited.append(label)
for i in list:
queue = [[label[0] + i[0], label[1] + i[1]]] + queue
cnt += 1
return -1
if __name__ == '__main__':
n = int(input())
d = list(map(int, input().split()))
x, y = [int(i) for i in input().split()]
tmp = []
for i in d:
tmp = tmp + chevyshev(i)
print(bfs(tmp, x, y))
leno