結果

問題 No.1016 三目並べ
ユーザー ferinferin
提出日時 2020-04-03 22:10:37
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,450 bytes
コンパイル時間 2,086 ms
コンパイル使用メモリ 194,068 KB
最終ジャッジ日時 2025-01-09 13:04:47
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

void solve() {
    ll n;
    string s;
    cin >> n >> s;

    REP(i, n-2) {
        string str = s.substr(i, 3);
        if(str == "ooo" || str == "oo-" || str == "-oo") {
            cout << "O\n";
            return;
        }
    }
    REP(i, n-3) {
        string str = s.substr(i, 4);
        if(str == "-o--" || str == "--o-") {
            cout << "O\n";
            return;
        }
    }
    ll con = 0;
    bool ok = false;
    REP(i, n) {
        if(s[i]=='o') {
            if(ok) {
                if(con%2) {
                    cout << "O\n";
                    return;
                }
            }
            ok = true;
            con = 0;
        } else if(s[i]=='-') {
            if(ok) con++;
        } else if(s[i]=='x') {
            ok = false;
        }
    }
    cout << "X\n";
}

int main(void) {
    ll t;
    cin >> t;
    while(t--) solve();

    return 0;
}
0