結果

問題 No.1016 三目並べ
ユーザー IKyoproIKyopro
提出日時 2020-04-03 21:51:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,220 bytes
コンパイル時間 1,980 ms
コンパイル使用メモリ 199,864 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-16 01:08:19
合計ジャッジ時間 2,679 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

void solve(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    if(N<=2){
        cout << "X\n";
        return ;
    }
    int l = 0;
    bool ok = false;
    while(l<N){
        int r = l;
        while(r<N && S[l]==S[r]) r++;
        if(S[l]=='o'){
            if(r-l>=3) ok = true;
            if(r-l==1){
                if(2<=l && r<N && S[l-1]=='-' && S[l-2]== '-' && S[r]=='-') ok = true;
                if(1<=l && r+1<N && S[l-1]=='-' && S[r]== '-' && S[r+1]=='-') ok = true;
                
            }
        }
        if(S[l]=='-'){
            if(l>=2 && S[l-1]=='o' && S[l-2]=='o') ok = true;
            if(r+1<N && S[r]=='o' && S[r+1]=='o') ok = true;
            if(l>=1 && r<N && S[l-1]=='o' && S[r]=='o'){
                int len = r-l;
                if(len%2) ok = true;
            }
        }
        l = r;
    }
    cout << (ok? "O\n":"X\n");
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int T;
    cin >> T;
    while(T--){
        solve();
    }
}
0