結果

問題 No.3606 Ice Grid Game
コンテスト
ユーザー tassei903
提出日時 2026-07-31 22:08:35
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 141 ms / 2,000 ms
+ 956µs
コード長 2,424 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 228 ms
コンパイル使用メモリ 95,984 KB
実行使用メモリ 86,528 KB
最終ジャッジ日時 2026-07-31 22:08:38
合計ジャッジ時間 2,841 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
# input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################

"""

ある色について,

色 i で長さ j にをとるときの最大値

"""

from functools import cache

def naive(h, w, r, c):

    @cache
    def saiki(now, x, y):
        # print(bin(now), x, y)
        
        for dx, dy in [[1, 0], [-1, 0], [0, 1],[0, -1]]:
            nx = x + dx
            ny = y + dy
            if 0 <= nx < h and 0 <= ny < w and not (now >> (nx * w + ny) & 1):
                z = now
                nx = x
                ny = y
                while 0 <= nx + dx < h and 0 <= ny + dy < w and not (now >> ((nx + dx) * w + ny + dy) & 1):
                    z |= 1 << (nx * w + ny)
                    nx += dx
                    ny += dy
                if not saiki(z, nx, ny):
                    # print(x, y, 1)
                    # for i in range(h):
                    #     print("".join([str(now >> (i * w + j) & 1) for j in range(w)]))
                    # print()
                    return 1
   
        # print(x, y, 0)
        # for i in range(h):
        #     print("".join([str(now >> (i * w + j) & 1) for j in range(w)]))
        # print()
        return 0
    
    return saiki(0, r, c)

def solve(h, w, r, c):

    if h == w == 1:
        return 0
    if h == w == 7 and r == c == 3:
        return 0
    return 1
        

# # print(naive(3, 3, 0, 0))
# for h in range(1, 200, 2):
#     w = h
#     r = h // 2
#     c = w // 2
#     if solve(h, w, r, c) != naive(h, w, r, c):
#         print(h, w, r, c, solve(h, w, r, c), naive(h, w, r, c))


# for h in range(1, 30):
#     for w in range(h, h + 1):
#         f = [[0] * w for i in range(h)]
#         for r in range(h):
#             for c in range(w):
#                 if solve(h, w, r, c) != naive(h, w, r, c):
#                     print(h, w, r, c)
#                 f[r][c] = naive(h, w, r, c)
#         # print(h, w)
#         # for i in range(h):
#         #     print(*f[i])
#         # print()

for _ in range(ni()):
    h, w, r, c = na()
    r -= 1
    c -= 1
    if solve(h, w, r, c):
        print("Alice")
    else:
        print("Bob")
0