結果
| 問題 |
No.323 yuki国
|
| コンテスト | |
| ユーザー |
ぴろず
|
| 提出日時 | 2015-12-15 20:47:30 |
| 言語 | Python2 (2.7.18) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,032 bytes |
| コンパイル時間 | 491 ms |
| コンパイル使用メモリ | 7,068 KB |
| 実行使用メモリ | 30,336 KB |
| 最終ジャッジ日時 | 2024-09-15 13:08:09 |
| 合計ジャッジ時間 | 37,259 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 26 TLE * 6 |
ソースコード
#!/usr/bin/python
from collections import deque
h,w = map(int, raw_input().split())
a,si,sj = map(int,raw_input().split())
b,gi,gj = map(int,raw_input().split())
if ((abs(si-gi) ^ abs(sj-gj) ^ a ^ b) & 1) == 1:
print("No")
quit()
m = [raw_input() for i in range(h)]
ma = max(a+h+w-1,b+2*(h+w))
used = [[[False] * (ma+1) for j in range(w)] for i in range(h)]
d = [0,1,0,-1]
q = deque([a << 16 | si << 8 | sj]);
used[si][sj][a] = True
while len(q) > 0:
p = q.popleft()
cs = p >> 16
ci = p >> 8 & 0xff
cj = p & 0xff
for i in range(4):
ni = ci + d[i]
nj = cj + d[i^1]
if ni < 0 or ni >= h or nj < 0 or nj >= w :
continue
ns = cs + (1 if m[ni][nj] == '*' else -1)
if ns > ma or ns <= 0 or used[ni][nj][ns]:
continue
used[ni][nj][ns] = True
if (ni == gi and nj == gj and ns == b):
q.clear()
break
else:
q.append(ns << 16 | ni << 8 | nj)
print("Yes" if used[gi][gj][b] else "No")
ぴろず