結果

問題 No.2463 ストレートフラッシュ
ユーザー aaaaaaaaaa2230
提出日時 2023-09-08 22:48:50
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 595 bytes
コンパイル時間 206 ms
コンパイル使用メモリ 82,460 KB
実行使用メモリ 101,840 KB
最終ジャッジ日時 2024-06-26 16:04:40
合計ジャッジ時間 5,227 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 TLE * 1 -- * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
NM = [list(map(int,input().split())) for i in range(n*m)]

ans = 10**10

def calc(x,y):

    if x == n-1:
        target = set([1,n,n-1,n-2,n-3])
    else:
        target = set([x-2,x-1,x,x+1,x+2])

    
    num = 0

    turn = -1
    now = 0
    while num < 5:

        turn += 1

        dif = 5-num

        for i in range(dif):
            nx,ny = NM[now]
            now += 1
            if ny == y and nx in target:
                num += 1
        
    return turn
for i in range(3,n):
    for j in range(1,m+1):
        ans = min(ans,calc(i,j))

print(ans)
0