結果

問題 No.1016 三目並べ
ユーザー outlineoutline
提出日時 2021-02-08 23:08:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,013 bytes
コンパイル時間 1,261 ms
コンパイル使用メモリ 132,592 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 07:49:49
合計ジャッジ時間 2,243 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 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 AC 3 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <array>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
using namespace std;

using ll = long long;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

void solve(){
    int N;
    string S;
    cin >> N >> S;
    for(int i = 0; i + 2 < N; ++i){
        if(S[i] == 'o' && S[i + 1] == 'o' && S[i + 2] == 'o'){
            cout << "O\n";
            return;
        }
    }
    for(int i = 0; i < N; ++i){
        if(S[i] == '-'){
            if(i - 2 >= 0 && S[i - 2] == 'o' && S[i - 1] == 'o'){
                cout << "O\n";
                return;
            }
            if(i + 2 < N && S[i + 1] == 'o' && S[i + 2] == 'o'){
                cout << "O\n";
                return;
            }
        }
    }
    for(int i = 0; i + 1 < N; ){
        if(S[i] == 'o' && S[i + 1] == '-'){
            int cnt = 1, j = i + 2;
            while(j < N && S[j] == '-'){
                ++cnt;
                ++j;
            }
            if(j < N && S[j] == 'o' && cnt % 2 == 1){
                cout << "O\n";
                return;
            }
            i = j;
        }
        else    ++i;
    }
    cout << "X\n";
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
    cin >> T;
    while(T--)  solve();
    
    return 0;
}
0