結果

問題 No.1016 三目並べ
ユーザー parukiparuki
提出日時 2020-04-10 21:06:54
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,813 bytes
コンパイル時間 1,908 ms
コンパイル使用メモリ 200,384 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-13 17:50:20
合計ジャッジ時間 2,585 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 2 ms
4,352 KB
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<0 || i + 3 > N) return -1;
            int x = 0, o = 0, k = -1;
            FOR(j, i, i + 3) {
                if (S[j] == 'x')x++;
                else if (S[j] == 'o')o++;
                else k = j;
            }
            if (o == 3)return N;
            else if (x == 0 && o >= 2) return k;
            else return -1;
        };

        rep(i, N) if (f(i) != -1) ans = 'O';
        
        // ダブルリーチを作る
        if (ans != 'O') {
            FOR(i, 1, N - 1) if (S[i] == '-') {
                S[i] = 'o';
                int A = 0, B = 0;
                for (int j = i - 2; j <= i; ++j) {
                    int fj = f(j);
                    if (fj >= 0 && fj < i)A = 1;
                    if (fj > i && fj < N)B = 1;
                }
                if (A&&B) {
                    ans = 'O';
                }
                S[i] = '-';
            }
        }

        cout << ans << endl;
    }
}

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