結果
| 問題 |
No.1016 三目並べ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-05 20:51:05 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 2,000 ms |
| コード長 | 969 bytes |
| コンパイル時間 | 1,910 ms |
| コンパイル使用メモリ | 194,748 KB |
| 最終ジャッジ日時 | 2025-01-09 14:24:14 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 10 |
ソースコード
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
ios::sync_with_stdio(false); cin.tie(0);
auto solve = [] () {
int n;
cin >> n;
string s;
cin >> s;
for (int i = 0; i + 2 < n; i++) {
if (s.substr(i, 3) == "ooo") return "O\n";
}
for (int i = 0; i < n; i++) {
if (s[i] == '-') {
s[i] = 'o';
for (int j = max(0, i - 2); j <= i; j++) {
if (s.substr(j, 3) == "ooo") return "O\n";
}
for (int j = max(0, i - 3); j <= i; j++) {
if (s.substr(j, 4) == "-oo-") return "O\n";
}
s[i] = '-';
}
}
bool f = false;
int p = 0;
for (int i = 0; i < n; i++) {
if (s[i] == 'o') {
if (f && (i - p) > 0 && (i - p) % 2 == 0) return "O\n";
f = true;
p = i;
}
if (s[i] == 'x') f = false;
}
return "X\n";
};
int t;
cin >> t;
while (t--) cout << solve();
return 0;
}