結果

問題 No.1016 三目並べ
ユーザー carrot46carrot46
提出日時 2020-04-03 22:22:55
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,542 bytes
コンパイル時間 1,602 ms
コンパイル使用メモリ 168,688 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-16 02:38:35
合計ジャッジ時間 2,258 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;

int main() {
    cin>>Q;
    rep(roop,Q){
        //cout<<roop<<endl;
        cin>>N>>S;
        string T = "x";
        T.append(S);
        T.push_back('x');
        N += 2;
        vec x_id(0);
        rep(i,N) if(T[i] == 'x') x_id.push_back(i);
        int sz = x_id.size();
        rep(i, sz - 1){
            int l = x_id[i] + 1, r = x_id[i + 1];
            //cout<<l<<' '<<r<<endl;
            if(r - l >= 3) {
                int num = 0;
                reps(j, l + 1, r - 1) num += T[j] == 'o';
                if (r - l == 3) {
                    num += T[l] == 'o';
                    num += T[r - 1] == 'o';
                    if (num >= 2) {
                        cout << 'O' << endl;
                        break;
                    }
                } else if (num > 0 || (T[l] == 'o' && T[r - 1] == 'o' && ((r - l) & 1))) {
                    cout << 'O' << endl;
                    break;
                }
            }
            if(i == sz - 2){
                cout<<'X'<<endl;
            }
        }
    }
}
0