結果
| 問題 | No.1016 三目並べ |
| コンテスト | |
| ユーザー |
zjsdut
|
| 提出日時 | 2025-11-28 01:07:22 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 943 bytes |
| コンパイル時間 | 1,868 ms |
| コンパイル使用メモリ | 195,768 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-11-28 01:07:25 |
| 合計ジャッジ時間 | 2,668 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 10 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int n;
string s;
cin >> n >> s;
bool win = false;
for (int i = 0; i < n; i++) {
string t3 = s.substr(i, 3);
string t4 = s.substr(i, 4);
if (t3 == "ooo" || t3 == "-oo" || t3 == "oo-" || t4 == "-o--" || t4 == "--o-") {
win = true;
break;
}
}
if (!win) {
int last_o = -1;
for (int i = 0; i < n; i++) {
if (s[i] == 'o') {
if (last_o != -1 && (i - last_o) % 2 == 0) {
win = true;
break;
}
last_o = i;
} else if (s[i] == 'x') {
last_o = -1;
}
}
}
cout << "XO"[win] << '\n';
}
}
zjsdut