結果
| 問題 |
No.1016 三目並べ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-03 21:45:31 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,073 bytes |
| コンパイル時間 | 1,568 ms |
| コンパイル使用メモリ | 168,708 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-03 01:57:30 |
| 合計ジャッジ時間 | 2,497 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 WA * 6 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
string a = "-o--";
string b = "--o-";
string c = "ooo";
string d = "oo-";
string e = "-oo";
void solve() {
int n; string s;
cin >> n >> s;
auto judge = [&](int i, string &t) {
if (i + t.size() >= n) return false;
for (int j = 0; j < t.size(); j++) {
if (s[i+j] != t[j]) return false;
}
return true;
};
bool ok = false;
for (int i = 0; i < n; i++) {
ok |= judge(i, a);
ok |= judge(i, b);
ok |= judge(i, c);
ok |= judge(i, d);
ok |= judge(i, e);
}
int c = 0;
for (int i = 0; i < n; i++) {
if (s[i] == '-') c++;
else {
if ((c & 1) && c != i) {
if (s[i-c-1] == 'o' && s[i] == 'o') {
ok = true;
}
}
c = 0;
}
}
if (ok) cout << "O\n";
else cout << "X\n";
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int t; cin >> t;
while (t--) solve();
return 0;
}