結果

問題 No.1016 三目並べ
コンテスト
ユーザー tktk_snsn
提出日時 2020-04-03 22:20:02
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 596 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 583 ms
コンパイル使用メモリ 20,828 KB
実行使用メモリ 15,356 KB
最終ジャッジ日時 2026-03-24 11:00:28
合計ジャッジ時間 2,624 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 5 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

win3 = set([
    "ooo",
    "oo-",
    "o-o",
    "-oo",
])
win4 = set([
    "--o-",
    "-o--",
])


def game(N, S):
    for i in range(N - 2):
        if S[i] + S[i + 1] + S[i + 2] in win3:
            return True
    for i in range(N - 3):
        if S[i] + S[i + 1] + S[i + 2] + S[i + 3] in win4:
            return True
    return False


if __name__ == "__main__":
    T = int(input())
    ans = []
    for _ in range(T):
        _, S = input().split()
        N = len(S)
        if game(N, S):
            ans.append("O")
        else:
            ans.append("X")
    print(*ans, sep="\n")
0