結果
問題 | No.2157 崖 |
ユーザー | MasKoaTS |
提出日時 | 2022-12-09 22:16:50 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,298 bytes |
コンパイル時間 | 250 ms |
コンパイル使用メモリ | 82,124 KB |
実行使用メモリ | 131,132 KB |
最終ジャッジ日時 | 2024-04-22 22:24:52 |
合計ジャッジ時間 | 11,402 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 138 ms
86,156 KB |
testcase_01 | AC | 141 ms
86,400 KB |
testcase_02 | AC | 146 ms
86,016 KB |
testcase_03 | AC | 144 ms
86,400 KB |
testcase_04 | AC | 140 ms
86,400 KB |
testcase_05 | AC | 153 ms
89,344 KB |
testcase_06 | AC | 141 ms
86,400 KB |
testcase_07 | AC | 151 ms
88,832 KB |
testcase_08 | AC | 143 ms
86,656 KB |
testcase_09 | AC | 151 ms
89,088 KB |
testcase_10 | AC | 138 ms
86,400 KB |
testcase_11 | AC | 160 ms
89,216 KB |
testcase_12 | AC | 136 ms
86,656 KB |
testcase_13 | TLE | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
ソースコード
import itertools as iter import collections as coll import heapq as hq import bisect as bis from decimal import Decimal as dec from functools import cmp_to_key import math import sys #import pypyjit #pypyjit.set_param('max_unroll_recursion=-1') sys.setrecursionlimit(10 ** 6) inp = sys.stdin.readline input = lambda : inp().rstrip() getN = lambda : int(inp()) getNs = lambda : map(int, inp().split()) getList = lambda :list(map(int, inp().split())) getStrs = lambda n : [input() for _ in [0] * n] def yexit(): print("Yes"); exit(0) def nexit(): print("No"); exit(0) pi = 3.141592653589793 mod = 1000000007 MOD = 998244353 INF = 4611686018427387903 dx = [1, 0, -1, 0]; dy = [0, 1, 0, -1] #di = coll.defaultdict(int) """ Main Code """ n, m = getNs() D = [sorted(getNs()) for _ in [0]*n] def check(mid): stk = [*range(m)] visited = set(stk) while(stk): # print(mid, stk) v = stk.pop() i = v // m; j = v % m if(i == n - 1): return True ni = i + 1 for nj in range(m): next = ni * m + nj if(next in visited or not(0 <= D[ni][nj] - D[i][j] <= mid)): continue visited.add(next) stk.append(next) return False ok = 10 ** 10 ng = -1 while(ok - ng > 1): mid = (ok + ng) // 2 if(check(mid)): ok = mid else: ng = mid if(ok > 10 ** 9): print(-1) else: print(ok)