結果

問題 No.1016 三目並べ
ユーザー milanis48663220milanis48663220
提出日時 2020-04-03 22:52:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,559 bytes
コンパイル時間 701 ms
コンパイル使用メモリ 83,320 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-16 04:00:06
合計ジャッジ時間 1,369 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int T;
    cin >> T;
    for(int d = 0; d < T; d++){
        int N;
        string S;
        cin >> N >> S;
        bool ok = false;
        for(int i = 0; i+2 < N; i++){
            if(S[i] == 'o' && S[i+1] == 'o' && S[i+2] == '-') ok = true;
            if(S[i] == '-' && S[i+1] == 'o' && S[i+2] == 'o') ok = true;
            if(S[i] == 'o' && S[i+1] == '-' && S[i+2] == 'o') ok = true;
            if(S[i] == 'o' && S[i+1] == 'o' && S[i+2] == 'o') ok = true;
        }
        for(int i = 0; i+3 < N; i++){
            if(S[i] == '-' && S[i+1] == 'o' && S[i+2] == '-' && S[i+3] == '-') ok = true;
            if(S[i] == '-' && S[i+1] == '-' && S[i+2] == 'o' && S[i+3] == '-') ok = true;
        }
        int cnto = 0;
        int cntx = 0;
        int cnt_ = 0;
        for(int i = 0; i < N; i++){
            if(S[i] == 'x') {
                cntx++;
            }
            if(S[i] == '-') cnt_++;
            if(S[i] == 'o'){
                if((cnt_ == 1) && (cntx == 0)) {
                    if(ok == false) return -1;
                    // ok = true;
                }
                // if(cnt_%2 == 1 ) ok = true;
                cnt_ = 0;
                cntx = 0;
            }
        }
        if(ok) cout << 'O' << endl;
        else cout << 'X' << endl;
    }
}
0