結果
| 問題 |
No.1016 三目並べ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-03 22:35:53 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 1,149 bytes |
| コンパイル時間 | 705 ms |
| コンパイル使用メモリ | 73,396 KB |
| 最終ジャッジ日時 | 2025-01-09 13:17:44 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 10 |
ソースコード
#include <iostream>
#include <algorithm>
#include <string>
void solve() {
int n;
std::string s;
std::cin >> n >> s;
bool ans = false;
for (int i = 0; i < n; ++i) {
if (s.substr(i, 4) == "--o-" ||
s.substr(i, 4) == "-o--") ans = true;
}
for (int i = 0; i < 2; ++i) {
int c1 = -1, c2 = -1;
for (auto c : s) {
if (c == 'x') {
c1 = c2 = -1;
} else {
int c0 = (c == 'o');
if ((c1 == 1 && c2 == 1) ||
(c0 == 1 && c2 == 1) ||
(c0 == 1 && c1 == 1 && c2 != -1)) {
ans = true;
}
if (c2 == 1) {
c0 = 1;
c1 = -1;
}
c2 = c1;
c1 = c0;
}
}
std::reverse(s.begin(), s.end());
}
std::cout << (ans ? 'O' : 'X') << std::endl;
}
int main() {
std::cin.tie(nullptr);
std::cout.tie(nullptr);
std::ios::sync_with_stdio(false);
int q;
std::cin >> q;
while (q--) solve();
return 0;
}