結果
問題 | No.1016 三目並べ |
ユーザー | potoooooooo |
提出日時 | 2020-04-03 21:56:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,072 bytes |
コンパイル時間 | 1,614 ms |
コンパイル使用メモリ | 168,508 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-03 02:26:02 |
合計ジャッジ時間 | 2,063 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 10 |
ソースコード
#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; }