結果

問題 No.1016 三目並べ
コンテスト
ユーザー zjsdut
提出日時 2025-11-28 00:51:57
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 797 bytes
コンパイル時間 1,917 ms
コンパイル使用メモリ 195,372 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2025-11-28 00:52:00
合計ジャッジ時間 2,807 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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 - 3; i++) {
            string t = s.substr(i, 3);
            if (t == "ooo" || t == "-oo" || t == "oo-") {
                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;
                }
            }
        }
        cout << "XO"[win] << '\n';
    }
}
0