結果

問題 No.1016 三目並べ
ユーザー auauaauaua
提出日時 2020-04-03 23:10:42
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,469 bytes
コンパイル時間 1,798 ms
コンパイル使用メモリ 167,760 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-16 04:27:26
合計ジャッジ時間 2,397 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll t;cin>>t;
    while(t){
        t--;
        ll n;string s;cin>>n>>s;
        string a="xxxx";
        string b="";
        b+=a+s+a;
        bool f=0;
        ll last=-1;
        ll cnt=0;
        rep(i,n){
            ll c=i+4;
            if(b[c]=='x')cnt=0;
            if(b[c]=='-'&&cnt>0)cnt++;
            if(b[c]=='o'){
                cnt++;
                if(cnt%2&&cnt>1)f=1;
                cnt=1;
            }
            if(b[c]=='o'&&b[c+1]=='-'&&b[c+2]=='o')f=1;
            if(b[c]=='o'&&b[c+1]=='o'&&b[c+2]=='-')f=1;
            if(b[c]=='-'&&b[c+1]=='o'&&b[c+2]=='o')f=1;
            if(b[c]=='o'&&b[c+1]=='o'&&b[c+2]=='o')f=1;
            if(b[c]=='o'&&b[c+1]=='-'&&b[c+2]=='o'&&b[c+3]=='-'&&b[c+4]=='o')f=1;
            if(b[c]=='-'&&b[c+1]=='o'&&b[c+2]=='-'&&b[c+3]=='-')f=1;
            if(b[c]=='-'&&b[c+1]=='-'&&b[c+2]=='o'&&b[c+3]=='-')f=1;
            if(b[c]=='o'&&b[c+1]=='-'&&b[c+2]=='-'&&b[c+3]=='-'&&b[c+4]=='o')f=1;
        }
        if(f)cout<<'O'<<endl;
        else cout<<'X'<<endl;
    }
}
0