結果

問題 No.1016 三目並べ
ユーザー もりをもりを
提出日時 2020-04-03 21:57:52
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 568 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 86,872 KB
実行使用メモリ 77,208 KB
最終ジャッジ日時 2023-09-16 01:25:16
合計ジャッジ時間 1,914 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,260 KB
testcase_01 AC 67 ms
71,328 KB
testcase_02 AC 66 ms
71,140 KB
testcase_03 AC 73 ms
75,484 KB
testcase_04 AC 74 ms
75,464 KB
testcase_05 AC 71 ms
71,280 KB
testcase_06 AC 72 ms
75,524 KB
testcase_07 AC 90 ms
77,208 KB
testcase_08 AC 89 ms
76,996 KB
testcase_09 AC 91 ms
77,104 KB
testcase_10 AC 91 ms
77,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import groupby

T = int(input())

def check(s, pattern):
    return s.count(pattern) > 0

for _ in range(T):
    _, s = input().split()
    ok = False
    ok |= check(s, 'ooo')
    ok |= check(s, 'oo-')
    ok |= check(s, '-oo')
    ok |= check(s, '-o--')
    ok |= check(s, '--o-')
    gb = groupby(list(s))
    gbl = [(k, len(list(v))) for k, v in gb]
    for i in range(len(gbl) - 2):
        a,b,c = gbl[i : i + 3]
        if a[0] == 'o' and b[0] == '-' and c[0] == 'o' and b[1] % 2 == 1:
            ok = True
            break
    print("XO"[ok])
0