結果
| 問題 |
No.1016 三目並べ
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 14:52:51 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 989 bytes |
| コンパイル時間 | 181 ms |
| コンパイル使用メモリ | 82,816 KB |
| 実行使用メモリ | 64,768 KB |
| 最終ジャッジ日時 | 2025-06-12 14:55:54 |
| 合計ジャッジ時間 | 1,358 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 10 |
ソースコード
def determine_winner(n, s):
# Check if current s has three consecutive 'o's
if has_three_o(s):
return "O"
# Check if O can win in the next move
for i in range(n):
if s[i] == '-':
# Check three possible patterns
# Pattern 1: left two are 'o's
if i >= 2 and s[i-2] == 'o' and s[i-1] == 'o':
return "O"
# Pattern 2: left and right are 'o's
if i >= 1 and i < n-1 and s[i-1] == 'o' and s[i+1] == 'o':
return "O"
# Pattern 3: right two are 'o's
if i <= n-3 and s[i+1] == 'o' and s[i+2] == 'o':
return "O"
# If none of the above, X wins
return "X"
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()
n = int(n)
print(determine_winner(n, s))
gew1fw