結果

問題 No.1016 三目並べ
ユーザー divinediscon10tdivinediscon10t
提出日時 2020-04-03 22:56:44
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,598 bytes
コンパイル時間 1,533 ms
コンパイル使用メモリ 166,116 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-16 04:06:28
合計ジャッジ時間 2,245 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll T;
    cin >> T;
    zep(t, 0, T){
        ll n; string s; cin >> n >> s;

        bool ans = false;

        zep(i, 0, n){
            if(i+2 < n && s[i] == 'o' && s[i+1] == 'o' && s[i+2] == 'o'){ans = true;}
            if(i+1 < n && s[i] == 'o' && s[i+1] == 'o' && ((i-1 >= 0 && s[i-1] == '-') || (i+2 < n && s[i+2] == '-'))){ans = true;}
            if(i+2 < n && s[i] == '-' && s[i+1] == 'o' && s[i+2] == '-' && ((i-1 >= 0 && s[i-1] == '-') || (i+3 < n && s[i+3] == '-'))){ans = true;}
        }

        ll state = 0;
        ll cnt = 0;
        zep(i, 0, n){
            if(state == 0){
                if(s[i] == 'o'){
                    state = 1;
                }
            }
            else{
                if(s[i] == 'o'){
                    if(cnt%2 == 1){ans = true;}
                    cnt = 0;
                }
                if(s[i] == 'x'){
                    state = 0;
                    cnt = 0;
                }
                if(s[i] == '-'){
                    cnt++;
                }
            }
        }
        print((ans)? "O" : "X")
    }

    
    
    
    return 0;
}
0