結果

問題 No.1016 三目並べ
ユーザー parukiparuki
提出日時 2020-04-10 20:32:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,622 bytes
コンパイル時間 2,063 ms
コンパイル使用メモリ 199,852 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-13 16:53:45
合計ジャッジ時間 2,772 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

void solve() {
    int T;
    cin >> T;
    while (T--) {
        int N;
        string S;
        cin >> N >> S;
        char ans = 'X';
        auto f = [&](int i) {
            if (i + 3 > N)return false;
            int x = 0, o = 0;
            FOR(j, i, i + 3) {
                if (S[j] == 'x')x++;
                else if (S[j] == 'o')o++;
            }
            return x == 0 && o >= 2;
        };

        rep(i, N) {
            if (f(i)) {
                ans = 'O';
                break;
            }
        }
        
        // ダブルリーチを作れる
        rep(i, N) if (S[i] == '-') {
            S[i] = 'O';
            int cnt = 0;
            for (int j = max(0, i - 2); j <= i; ++j) {
                if (f(j))cnt++;
            }
            S[i] = '-';
            if (cnt >= 2) {
                ans = 'O';
                break;
            }
        }

        cout << ans << endl;
    }
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}
0