結果

問題 No.1016 三目並べ
ユーザー lemondolemondo
提出日時 2020-12-22 16:13:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 945 bytes
コンパイル時間 863 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 77,936 KB
最終ジャッジ日時 2023-10-21 12:59:35
合計ジャッジ時間 10,087 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,444 KB
testcase_01 AC 40 ms
53,444 KB
testcase_02 AC 40 ms
53,444 KB
testcase_03 AC 47 ms
59,468 KB
testcase_04 AC 46 ms
59,632 KB
testcase_05 AC 47 ms
61,632 KB
testcase_06 AC 45 ms
59,468 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 TLE -
testcase_10 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return list(map(int, input().split()))
sys.setrecursionlimit(10**9)

T = int(input())
def check(S):
    vic = 0
    vic_prob = set()
    length = len(S)
    for i in range(length-2):
        s = ''.join(S[i:i+3])
        if s=='ooo':
            vic += 1
        elif s=='oo-' or s=='-oo' or s=='o-o':
            vic_prob.add(i+('-oo', 'o-o', 'oo-').index(s))
    return vic, len(vic_prob)
        
        

for _ in range(T):
    N, S = input().split()
    N = int(N)
    S = list(S)
    if N<3:
        print('X')
        continue
    v, p = check(S)
    if v>0 or p>0:
        print('O')
        continue
    
    flg = False
    for i in range(N):
        if S[i]=='-':
            S[i] = 'o'
            v, p = check(S)
            if p > 1:
                flg = True
            S[i] = '-'
    if flg:
        print('O')
    else:
        print('X')
            
0