結果
問題 | No.1016 三目並べ |
ユーザー |
![]() |
提出日時 | 2025-06-12 19:51:02 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,240 bytes |
コンパイル時間 | 235 ms |
コンパイル使用メモリ | 82,044 KB |
実行使用メモリ | 64,744 KB |
最終ジャッジ日時 | 2025-06-12 19:51:08 |
合計ジャッジ時間 | 1,198 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | WA * 10 |
ソースコード
def main(): import sys input = sys.stdin.read().split() T = int(input[0]) idx = 1 for _ in range(T): N = int(input[idx]) S = input[idx+1] idx += 2 # Check if there are already three consecutive 'o's has_three = False for i in range(len(S)-2): if S[i] == 'o' and S[i+1] == 'o' and S[i+2] == 'o': has_three = True break if has_three: print('O') continue # Check if O can win in the next move can_win = False for i in range(len(S)): if S[i] != '-': continue # Check left two if i >= 2 and S[i-1] == 'o' and S[i-2] == 'o': can_win = True break # Check left and right if i >= 1 and i < len(S)-1 and S[i-1] == 'o' and S[i+1] == 'o': can_win = True break # Check right two if i < len(S)-2 and S[i+1] == 'o' and S[i+2] == 'o': can_win = True break if can_win: print('O') else: print('X') if __name__ == '__main__': main()