結果
問題 |
No.1016 三目並べ
|
ユーザー |
![]() |
提出日時 | 2025-06-12 14:52:44 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 877 bytes |
コンパイル時間 | 180 ms |
コンパイル使用メモリ | 82,368 KB |
実行使用メモリ | 69,536 KB |
最終ジャッジ日時 | 2025-06-12 14:55:41 |
合計ジャッジ時間 | 1,543 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | WA * 10 |
ソースコード
def has_three_consecutive_o(s): n = len(s) for i in range(n - 2): if s[i] == 'o' and s[i+1] == 'o' and s[i+2] == 'o': return True return False def can_o_win_next_move(s): n = len(s) for i in range(n): if s[i] != '-': continue # Check left two if i - 2 >= 0 and s[i-1] == 'o' and s[i-2] == 'o': return True # Check left and right if i - 1 >= 0 and i + 1 < n and s[i-1] == 'o' and s[i+1] == 'o': return True # Check right two if i + 2 < n and s[i+1] == 'o' and s[i+2] == 'o': return True return False T = int(input()) for _ in range(T): N, S = input().split() S = list(S) if has_three_consecutive_o(S): print("O") continue if can_o_win_next_move(S): print("O") else: print("X")