結果
問題 | No.1016 三目並べ |
ユーザー |
![]() |
提出日時 | 2025-03-26 15:52:10 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,260 bytes |
コンパイル時間 | 167 ms |
コンパイル使用メモリ | 82,408 KB |
実行使用メモリ | 87,244 KB |
最終ジャッジ日時 | 2025-03-26 15:52:50 |
合計ジャッジ時間 | 4,101 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | WA * 10 |
ソースコード
def has_three_consecutive_o(s):for i in range(len(s) - 2):if s[i] == 'o' and s[i+1] == 'o' and s[i+2] == 'o':return Truereturn Falsedef can_win_immediately(s):for i in range(len(s)):if s[i] == '-':new_s = list(s)new_s[i] = 'o'if has_three_consecutive_o(new_s):return Truereturn Falsedef find_max_consecutive_dash(s):max_len = 0current_len = 0for c in s:if c == '-':current_len += 1if current_len > max_len:max_len = current_lenelse:current_len = 0return max_lenT = int(input())for _ in range(T):N, S = input().split()N = int(N)S = S.strip()if has_three_consecutive_o(S):print("O")continueif can_win_immediately(S):print("O")continuecount_missing = S.count('-')if count_missing == 0:print("X")continueX_remaining = count_missing // 2max_dash_block = find_max_consecutive_dash(S)required_length = 2 * X_remaining + 1if max_dash_block >= required_length and max_dash_block >= 3:print("O")else:print("X")