結果

問題 No.1016 三目並べ
ユーザー lam6er
提出日時 2025-04-16 00:15:11
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 771 bytes
コンパイル時間 436 ms
コンパイル使用メモリ 82,096 KB
実行使用メモリ 73,804 KB
最終ジャッジ日時 2025-04-16 00:16:32
合計ジャッジ時間 1,484 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

def has_three_o(s):
    for i in range(len(s) - 2):
        if s[i] == 'o' 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 = S.strip()
    if has_three_o(S):
        print("O")
        continue
    c = S.count('-')
    m = (c + 1) // 2  # O's remaining moves
    possible = False
    for i in range(len(S) - 2):
        a = 0
        b = 0
        for j in range(3):
            if S[i + j] == 'o':
                a += 1
            elif S[i + j] == '-':
                b += 1
        needed = max(0, 3 - a)
        ceil_b = (b + 1) // 2  # ceil(b/2)
        if min(m, ceil_b) >= needed:
            possible = True
            break
    print("O" if possible else "X")
0