結果

問題 No.1016 三目並べ
ユーザー uni_pythonuni_python
提出日時 2020-04-04 09:17:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 1,071 bytes
コンパイル時間 258 ms
コンパイル使用メモリ 87,024 KB
実行使用メモリ 76,044 KB
最終ジャッジ日時 2023-09-16 05:27:51
合計ジャッジ時間 1,892 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,308 KB
testcase_01 AC 75 ms
71,236 KB
testcase_02 AC 69 ms
71,292 KB
testcase_03 AC 73 ms
71,152 KB
testcase_04 AC 71 ms
71,444 KB
testcase_05 AC 73 ms
71,532 KB
testcase_06 AC 74 ms
71,524 KB
testcase_07 AC 90 ms
75,884 KB
testcase_08 AC 90 ms
75,444 KB
testcase_09 AC 89 ms
75,300 KB
testcase_10 AC 93 ms
76,044 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

def main():
    T=I()
    for _ in range(T):
        a,S=input().split()
        N=int(a)
        S=["x","x"]+list(S)+["x","x"]
        now="x"
        length=1
        f=0
        for i in range(2,N+2):
            if S[i]==now:
                length+=1
            else:
                now=S[i]
                length=1
                
            if now=="o" and length==3:
                f=1
                break
            elif now=="o" and length==2 and (S[i-2]=="-" or S[i+1]=="-"):
                f=1
                break
            elif now=="o" and (S[i-1]=="-" and S[i+1]=="-") and(S[i-2]=="-" or S[i+2]=="-"):
                f=1
                break
            
            elif now=="-" and length%2==1 and (S[i-length]=="o" and S[i+1]=="o"):
                f=1
                break
            
        if f==1:
            print("O")
        else:
            print("X")
        
        
    
    


main()
0