結果

問題 No.1016 三目並べ
ユーザー lam6er
提出日時 2025-04-16 16:22:47
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 771 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 81,912 KB
実行使用メモリ 74,720 KB
最終ジャッジ日時 2025-04-16 16:23:57
合計ジャッジ時間 1,347 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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