結果

問題 No.1016 三目並べ
ユーザー gew1fw
提出日時 2025-06-12 19:56:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 877 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 82,148 KB
実行使用メモリ 68,648 KB
最終ジャッジ日時 2025-06-12 19:57:04
合計ジャッジ時間 1,264 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

def has_three_consecutive_o(s):
    n = len(s)
    for i in range(n - 2):
        if s[i] == 'o' and s[i+1] == 'o' and s[i+2] == 'o':
            return True
    return False

def can_o_win_next_move(s):
    n = len(s)
    for i in range(n):
        if s[i] != '-':
            continue
        # Check left two
        if i - 2 >= 0 and s[i-1] == 'o' and s[i-2] == 'o':
            return True
        # Check left and right
        if i - 1 >= 0 and i + 1 < n and s[i-1] == 'o' and s[i+1] == 'o':
            return True
        # Check right two
        if i + 2 < n and s[i+1] == 'o' and s[i+2] == 'o':
            return True
    return False

T = int(input())
for _ in range(T):
    N, S = input().split()
    S = list(S)
    if has_three_consecutive_o(S):
        print("O")
        continue
    if can_o_win_next_move(S):
        print("O")
    else:
        print("X")
0