結果
問題 | No.2708 Jewel holder |
ユーザー |
|
提出日時 | 2024-11-01 20:45:52 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 39 ms / 2,000 ms |
コード長 | 537 bytes |
コンパイル時間 | 205 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,520 KB |
最終ジャッジ日時 | 2024-11-01 20:45:54 |
合計ジャッジ時間 | 1,513 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
from collections import deque h,w=map(int,input().split()) a=[list(input()) for _ in range(h)] roots=deque([[(0,0,1)]]) count=0 while roots: t=roots.popleft() x,y,c=t[-1] if x==h-1 and y==w-1: count+=1 continue if x+1<h and ( a[x+1][y]=="o" or ( a[x+1][y]=="x" and c>0 ) ): d= c-1 if a[x+1][y]=="x" else c+1 g=t.copy() g.append((x+1,y,d)) roots.append(g) if y+1<w and ( a[x][y+1]=="o" or ( a[x][y+1]=="x" and c>0 ) ): d= c-1 if a[x][y+1]=="x" else c+1 g=t.copy() g.append((x,y+1,d)) roots.append(g) print(count)