結果
| 問題 |
No.1016 三目並べ
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-16 00:16:43 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 771 bytes |
| コンパイル時間 | 440 ms |
| コンパイル使用メモリ | 82,640 KB |
| 実行使用メモリ | 74,316 KB |
| 最終ジャッジ日時 | 2025-04-16 00:18:15 |
| 合計ジャッジ時間 | 1,382 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 10 |
ソースコード
def has_three_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
T = int(input())
for _ in range(T):
N, S = input().split()
S = S.strip()
if has_three_o(S):
print("O")
continue
c = S.count('-')
m = (c + 1) // 2 # O's remaining moves
possible = False
for i in range(len(S) - 2):
a = 0
b = 0
for j in range(3):
if S[i + j] == 'o':
a += 1
elif S[i + j] == '-':
b += 1
needed = max(0, 3 - a)
ceil_b = (b + 1) // 2 # ceil(b/2)
if min(m, ceil_b) >= needed:
possible = True
break
print("O" if possible else "X")
lam6er