結果

問題 No.1016 三目並べ
ユーザー lemondolemondo
提出日時 2020-12-22 16:38:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 1,172 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 81,800 KB
実行使用メモリ 75,220 KB
最終ジャッジ日時 2023-10-21 13:00:05
合計ジャッジ時間 1,439 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,544 KB
testcase_01 AC 40 ms
53,544 KB
testcase_02 AC 36 ms
53,544 KB
testcase_03 AC 38 ms
53,544 KB
testcase_04 AC 38 ms
53,544 KB
testcase_05 AC 37 ms
53,544 KB
testcase_06 AC 37 ms
53,544 KB
testcase_07 AC 67 ms
75,204 KB
testcase_08 AC 65 ms
75,220 KB
testcase_09 AC 69 ms
75,152 KB
testcase_10 AC 77 ms
75,156 KB
権限があれば一括ダウンロードができます

ソースコード

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))
    cnt = 0
    o = False
    for i in range(length):
        if S[i]=='o':
            o = True
            if cnt % 2==1:
                vic += 1
            cnt = 0
        elif S[i]=='x':
            o = False
            cnt = 0
        else:
            if o:
                cnt += 1
    
    if length>=4:
        for i in range(length-3):
            s = ''.join(S[i:i+4])
            if s=='--o-' or s=='-o--':
                vic += 1
    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
    else:
        print('X')
            
0