結果

問題 No.2708 Jewel holder
ユーザー yaakiyu
提出日時 2024-03-31 14:04:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 2,180 bytes
コンパイル時間 258 ms
コンパイル使用メモリ 82,216 KB
実行使用メモリ 67,636 KB
最終ジャッジ日時 2024-09-30 18:55:41
合計ジャッジ時間 1,672 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

# competetive programming
#
# sys
import sys
#sys.setrecursionlimit(100000000)
if sys.version_info.minor >= 11:
# python3.114300
sys.set_int_max_str_digits(10000000)
input = lambda: sys.stdin.readline()[:-1]
### import
## pypy
#import pypyjit; pypyjit.set_param('max_unroll_recursion=-1') #
#from atcoder.dsu import DSU # UnionFind 使uf=DSU() ; uf.merge(u, v) ; uf.same(u, v) ; uf.leader(u) ; uf.size(u) ; uf.groups()
#from atcoder.scc import SCCGraph # SCC 使g=SCCGraph() ; g.add_edge(u, v) ; scc=g.scc()
#from atcoder.segtree import SegTree # 使tree=SegTree(, , ) ; tree.set(pos, x) ; tree.prod(left, right + 1) #
#import heapq # Priority Queue 使q=[...] ; heapq.heapify(q) ; heapq.heappush(q, item) ; heapq.heappop(q, item)
from collections import deque # Queue 使q=deque(lis) ; q.popleft(item) ; q.append(item)
#from collections import Counter # Counter
#from collections import defaultdict # defaultdict del
#from itertools import accumulate #
#from itertools import combinations #
#from bisect import bisect_left, bisect_right #
#from decimal import Decimal, getcontext; getcontext().prec = 100 #
###
#inf = float("inf")
#inf = 10**18
#mod = 998244353
#mod = 1000000007 # 10**9+7
di = ((0, 1), (1, 0))#, (1, 1), (1, -1), (-1, 1), (-1, -1)) # 8 44
INTIN = lambda: int(input())
def MAPIN(kansu=int):
return map(kansu, input().split())
LISTIN = lambda k=int: list(MAPIN(k))
h, w = MAPIN()
mas = [input() for i in range(h)]
bfs = deque([(0, 0, 1)])
ans = 0
while bfs:
nx, ny, njewel = bfs.popleft()
if nx == h-1 and ny == w-1:
ans += 1
continue
for dx, dy in di:
px, py = nx+dx, ny+dy
if px >= h or py >= w:
continue
if mas[px][py] == "#":
continue
if mas[px][py] == "o":
bfs.append((px, py, njewel+1))
else:
if njewel == 0:
continue
bfs.append((px, py, njewel-1))
print(ans)
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0