結果
問題 |
No.1016 三目並べ
|
ユーザー |
|
提出日時 | 2020-04-03 22:10:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 853 bytes |
コンパイル時間 | 811 ms |
コンパイル使用メモリ | 69,760 KB |
最終ジャッジ日時 | 2025-01-09 13:04:35 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 6 WA * 4 |
ソースコード
#include <iostream> #include <string> void solve() { int n; std::string s; std::cin >> n >> s; auto judge = [&](int l, int r) -> bool { for (int i = std::max(0, l); i < std::min(n, r); ++i) { if (s.substr(i, 3) == "ooo" || s.substr(i, 4) == "-oo-" || s.substr(i, 5) == "o-o-o") { return true; } } return false; }; bool ans = judge(0, n); for (int i = 0; i < n; ++i) { if (s[i] != '-') continue; s[i] = 'o'; if (judge(i - 5, i + 5)) ans = true; s[i] = '-'; } 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; }