結果

問題 No.1016 三目並べ
ユーザー gew1fw
提出日時 2025-06-12 15:08:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 730 bytes
コンパイル時間 438 ms
コンパイル使用メモリ 82,240 KB
実行使用メモリ 76,492 KB
最終ジャッジ日時 2025-06-12 15:09:12
合計ジャッジ時間 2,372 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

def has_triplet(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()
    N = int(N)
    count_o = S.count('o')
    count_x = S.count('x')
    rem = N - (count_o + count_x)
    if rem == 0:
        if has_triplet(S):
            print("O")
        else:
            print("X")
    else:
        found = False
        for i in range(N):
            if S[i] == '-':
                temp = S[:i] + 'o' + S[i+1:]
                if has_triplet(temp):
                    found = True
                    break
        if found:
            print("O")
        else:
            print("X")
0