結果
| 問題 |
No.1016 三目並べ
|
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2020-04-03 22:22:40 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,400 bytes |
| コンパイル時間 | 1,665 ms |
| コンパイル使用メモリ | 168,612 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-03 03:57:21 |
| 合計ジャッジ時間 | 2,670 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 6 WA * 4 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int tt;
cin >> tt;
while (tt--) {
int n;
cin >> n;
string s;
cin >> s;
auto cnt = [&] {
int res = 0;
for (int i = 0; i < n; ++i) {
if (s[i] == '-') {
res += (i and s[i - 2] == 'o' and s[i - 1] == 'o') or
(i and i + 1 < n and s[i - 1] == 'o' and s[i + 1] == 'o') or
(i + 2 < n and s[i + 1] == 'o' and s[i + 2] == 'o');
}
}
return res;
};
[&] {
for (int i = 0; i + 3 <= n; ++i) {
int o = count(begin(s) + i, begin(s) + (i + 3), 'o');
int x = count(begin(s) + i, begin(s) + (i + 3), 'x');
int _ = 3 - o - x;
if (o == 3 or (o == 2 and _ == 1)) {
cout << "O\n";
return;
}
}
for (int i = 0; i < n; ++i) {
if (s[i] == '-') {
s[i] = 'o';
if (cnt() >= 2) {
cout << "O\n";
return;
}
s[i] = '-';
}
}
for (int w = 2; w < n; w *= 2) {
for (int i = 0; i + w < n; ++i) {
if (s[i] == 'o' and s[i + w] == 'o') {
if (count(begin(s) + (i + 1), begin(s) + (i + w), '-') == w - 1) {
cout << "O\n";
}
}
}
}
cout << "X\n";
}();
}
}
risujiroh