結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 35 ms
53,432 KB
testcase_02 AC 35 ms
53,432 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
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 = 0
    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 += 1
    return vic, 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