結果

問題 No.1668 Grayscale
ユーザー harurunharurun
提出日時 2021-09-03 22:55:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,142 ms / 4,000 ms
コード長 405 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 82,028 KB
実行使用メモリ 224,928 KB
最終ジャッジ日時 2024-05-09 06:10:22
合計ジャッジ時間 5,498 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,276 KB
testcase_01 AC 35 ms
52,528 KB
testcase_02 AC 35 ms
53,072 KB
testcase_03 AC 35 ms
52,424 KB
testcase_04 AC 36 ms
52,204 KB
testcase_05 AC 35 ms
52,704 KB
testcase_06 AC 456 ms
224,312 KB
testcase_07 AC 425 ms
224,928 KB
testcase_08 AC 260 ms
154,872 KB
testcase_09 AC 1,142 ms
220,952 KB
testcase_10 AC 565 ms
128,948 KB
testcase_11 AC 43 ms
61,088 KB
testcase_12 AC 56 ms
68,560 KB
testcase_13 AC 91 ms
80,628 KB
testcase_14 AC 208 ms
102,336 KB
testcase_15 AC 129 ms
87,204 KB
testcase_16 AC 102 ms
77,260 KB
testcase_17 AC 84 ms
81,884 KB
testcase_18 AC 34 ms
52,564 KB
testcase_19 AC 35 ms
52,564 KB
testcase_20 AC 50 ms
66,232 KB
testcase_21 AC 58 ms
67,820 KB
testcase_22 AC 35 ms
53,484 KB
testcase_23 AC 35 ms
52,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin
pin=stdin.readline
H,W,N=map(int,pin().split())
C=[list(map(int,pin().split()))for _ in[0]*H]
d=[[]for _ in[0]*N]
for i in range(H):
 for j in range(W):
  d[C[i][j]-1].append((i,j))
a=s=1
for i in range(N):
 f=0
 for x,y in d[i]:
  for u,t in ((1,0),(0,1),(-1,0),(0,-1)):
   if 0<=x+u<H and 0<=y+t<W and s<=C[x+u][y+t]<C[x][y]:
    a+=1;f=1;s=C[x][y]
    break
  if f:break
print(a)
0