結果

問題 No.2064 Smallest Sequence on Grid
ユーザー kozykozy
提出日時 2022-09-02 22:08:46
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 845 bytes
コンパイル時間 225 ms
コンパイル使用メモリ 82,236 KB
実行使用メモリ 92,604 KB
最終ジャッジ日時 2024-04-27 21:43:18
合計ジャッジ時間 7,589 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
59,376 KB
testcase_01 AC 32 ms
52,328 KB
testcase_02 AC 30 ms
52,072 KB
testcase_03 AC 30 ms
52,864 KB
testcase_04 AC 31 ms
52,404 KB
testcase_05 AC 31 ms
54,148 KB
testcase_06 WA -
testcase_07 AC 31 ms
53,124 KB
testcase_08 AC 31 ms
53,280 KB
testcase_09 AC 34 ms
52,600 KB
testcase_10 AC 35 ms
53,220 KB
testcase_11 WA -
testcase_12 AC 36 ms
53,872 KB
testcase_13 WA -
testcase_14 AC 41 ms
59,852 KB
testcase_15 AC 39 ms
60,992 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 TLE -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W=map(int,input().split())
L=list()
for i in range(H):
  s=input()
  L.append(s)
ans=list()
ans.append(L[0][0])
A=[0,0]
def f(x,y):
  if 0<=x<H and 0<=y<W:
    return True
  return False

while True:
  if A[0]==H-1:
    for i in range(A[1]+1,W):
      ans.append(L[A[0]][i])
    break
  if A[1]==W-1:
    for i in range(A[0]+1,H):
      ans.append(L[i][A[1]])
    break
  c=L[A[0]][A[1]+1]
  flag=True
  for i in range(1,H+W+1):
    for s in range(0,i+1):
      if f(A[0]+s,A[1]+i-s):
        if L[A[0]+s][A[1]+i-s]!=c:
          flag=False
    if not flag:
      t="z"
      for s in range(0,i+1):
        if f(A[0]+s,A[1]+i-s):
          if t>=L[A[0]+s][A[1]+i-s]:
            P=[A[0]+s,A[1]+i-s]
            t=L[A[0]+s][A[1]+i-s]
      for j in range(i-1):
        ans.append(c)
      ans.append(t)
      A=P
      break
print("".join(ans))
0