結果

問題 No.1016 三目並べ
ユーザー kashibashimin94kashibashimin94
提出日時 2020-04-04 12:59:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 1,461 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 87,224 KB
実行使用メモリ 76,960 KB
最終ジャッジ日時 2023-09-16 05:37:49
合計ジャッジ時間 1,932 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,260 KB
testcase_01 AC 70 ms
71,500 KB
testcase_02 AC 70 ms
71,556 KB
testcase_03 AC 72 ms
71,288 KB
testcase_04 AC 71 ms
71,480 KB
testcase_05 AC 72 ms
71,548 KB
testcase_06 AC 73 ms
71,152 KB
testcase_07 AC 92 ms
76,308 KB
testcase_08 AC 92 ms
76,356 KB
testcase_09 AC 98 ms
76,960 KB
testcase_10 AC 90 ms
76,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t=int(input())
s=[input().split() for i in range(t)]

for i in range(t):
    v=int(s[i][0])
    if v<=2:
        print('X')
    elif v==3:
        if  '-oo'==s[i][1] or 'o-o'==s[i][1] or 'oo-'==s[i][1] or 'ooo'==s[i][1]:
            print('O')
        else:
            print('X')
    else:
        flag=True
        for j in range(v-2):
            if '-oo'==s[i][1][j:j+3] or 'oo-'==s[i][1][j:j+3] or 'ooo'==s[i][1][j:j+3]:
                print('O')
                flag=False
                break

        if flag:
            for j in range(v-3):
                if '-o--'==s[i][1][j:j+4] or '--o-'==s[i][1][j:j+4]:
                    print('O')
                    flag=False
                    break
            
            if flag:
                flag1 = True
                count = 0
                for j in range(v):
                    if (s[i][1][j] == 'o' and flag1) or (s[i][1][j] == 'o' and not flag1 and count % 2 == 0):
                        flag1 = False
                        count = 0
                    elif s[i][1][j] == 'x':
                        flag1 = True
                        count = 0
                    elif s[i][1][j] == '-':
                        count += 1
                    elif s[i][1][j] == 'o' and not flag1 and count % 2 == 1:
                        print('O')
                        flag = False
                        break
                
                if flag:
                    print('X')
0