結果

問題 No.1016 三目並べ
ユーザー hiikunZhiikunZ
提出日時 2021-07-18 11:49:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,641 bytes
コンパイル時間 1,946 ms
コンパイル使用メモリ 206,732 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 13:34:31
合計ジャッジ時間 2,649 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#include <atcoder/twosat>
using namespace std;
using namespace atcoder;
using ll = long long int;
using ld = long double;
const ll MAX = 5000000000000000000;
const ld PI = 3.14159265358979;
const ll MOD = 0;//2024948111;
ld dotorad(ld K){return PI * K / 180.0;}
ld radtodo(ld K){return K * 180.0 / PI;}
mt19937 mt;
void randinit(){srand((unsigned)time(NULL));mt = mt19937(rand());}
int main(){
    ll T;
    cin >> T;
    for(ll t = 0;t < T;t++){
        ll N;
        char ans = 'X';
        string S;
        cin >> N >> S;
        for(ll i = 0;i < N - 2;i++){
            if(S[i] == 'o' && S[i + 1] == 'o' && S[i + 2] == 'o') ans = 'O';
            if(S[i] == 'o' && S[i + 1] == '-' && S[i + 2] == 'o') ans = 'O';
            if(S[i] == 'o' && S[i + 1] == 'o' && S[i + 2] == '-') ans = 'O';
            if(S[i] == '-' && S[i + 1] == 'o' && S[i + 2] == 'o') ans = 'O';
        }
        for(ll i = 0;i < N - 3;i++){
            if(S[i] == '-' && S[i + 1] == 'o' && S[i + 2] == '-' && S[i + 3] == '-') ans = 'O';
            if(S[i] == '-' && S[i + 1] == '-' && S[i + 2] == 'o' && S[i + 3] == '-') ans = 'O';
        }
        for(ll i = 0;i < N - 1;i++){
            if(S[i] == 'o' && S[i + 1] == '-'){
                ll p = i;
                i++;
                while(S[i] == '-') i++;
                if(S[i] == 'o' && (i - p) % 2 == 0){
                    ans = 'O';
                }
            }
        }
        for(ll i = 0;i < N - 4;i++){
            if(S[i] == 'o' && S[i + 1] == '-' && S[i + 2] == '-' && S[i + 3] == '-' && S[i + 4] == 'o') ans = 'O';
        }
        cout << ans << endl;
    }
}
0