結果

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

ソースコード

diff #

T = int(input())
for _ in range(T):
    N, S = input().split()
    N = int(N)
    # Check existing triplets of 'o's
    existing = False
    for i in range(len(S) - 2):
        if S[i] == 'o' and S[i+1] == 'o' and S[i+2] == 'o':
            existing = True
            break
    if existing:
        print("O")
        continue
    # Check possible triplets after filling
    K = S.count('-')
    o_moves = (K + 1) // 2
    possible = False
    for i in range(len(S) - 2):
        # Check if any 'x' in the triplet
        if S[i] == 'x' or S[i+1] == 'x' or S[i+2] == 'x':
            continue
        # Count '-' in the triplet
        m = (S[i] == '-') + (S[i+1] == '-') + (S[i+2] == '-')
        if m <= o_moves:
            possible = True
            break
    print("O" if possible else "X")
0