結果

問題 No.1016 三目並べ
ユーザー lam6er
提出日時 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
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

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 True
return False
def 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 True
return False
def find_max_consecutive_dash(s):
max_len = 0
current_len = 0
for c in s:
if c == '-':
current_len += 1
if current_len > max_len:
max_len = current_len
else:
current_len = 0
return max_len
T = int(input())
for _ in range(T):
N, S = input().split()
N = int(N)
S = S.strip()
if has_three_consecutive_o(S):
print("O")
continue
if can_win_immediately(S):
print("O")
continue
count_missing = S.count('-')
if count_missing == 0:
print("X")
continue
X_remaining = count_missing // 2
max_dash_block = find_max_consecutive_dash(S)
required_length = 2 * X_remaining + 1
if max_dash_block >= required_length and max_dash_block >= 3:
print("O")
else:
print("X")
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0