結果

問題 No.1016 三目並べ
ユーザー ferinferin
提出日時 2020-04-03 22:10:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 1,450 bytes
コンパイル時間 1,897 ms
コンパイル使用メモリ 200,016 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-16 02:04:02
合計ジャッジ時間 2,522 ms
ジャッジサーバーID
(参考情報)
judge12 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 5 ms
4,376 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 6 ms
4,376 KB
testcase_10 AC 6 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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