結果

問題 No.1016 三目並べ
ユーザー kyort0nkyort0n
提出日時 2020-04-03 21:41:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,336 bytes
コンパイル時間 1,504 ms
コンパイル使用メモリ 166,936 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-16 00:42:41
合計ジャッジ時間 2,173 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;

bool check(string S) {
    //cerr << S << endl;
    ll num = 0;
    for(int i = 0; i < S.size(); i++) {
        if(S[i] == 'o') num++;
    }
    if(num >= 3) return true;
    if(num <= 1) return false;
    if((int)S.size() % 2 == 0 and S[0] == 'o' and S.back() == 'o') return false;
    return true;
}

void solve() {
    ll N;
    string S;
    cin >> N >> S;
    S = "x" + S + "x";
    ll Last = 0;
    for(int i = 1; i < S.size(); i++) {
        if(S[i] == 'x') {
            if(i - Last - 1 > 0 and check(S.substr(Last+1, i-Last-1))) {
                cout << "O" << endl;
                return;
            }
            Last = i;
        }
    }
    cout << "X" << endl;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    while(N--) solve();
    return 0;
}
0