結果

問題 No.1016 三目並べ
ユーザー むかでむかで
提出日時 2020-04-03 22:31:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,986 bytes
コンパイル時間 1,530 ms
コンパイル使用メモリ 170,908 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-16 03:16:04
合計ジャッジ時間 2,241 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 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,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 3 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>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t; cin>>t;
    while(t--){
        int n; cin>>n;
        string s; cin>>s;
        s="x"+s+"x";
        n=s.size();
        char now='x';
        using P = pair<char,int>;
        vector<P> r;
        int cnt=0;
        rep(i,n){
            if (s[i]==now) cnt++;
            else{
                r.emplace_back(now,cnt);
                now=s[i];
                cnt=1;
            }
        }
        r.emplace_back(now,cnt);
        bool ans=false;
        int sz=r.size();
        rep(i,sz){
            P e = r[i];
            if (e.fi=='o' && e.se>=3) ans=true;
            if (e.fi=='o' && e.se==2 && (r[i-1].fi=='-'||r[i+1].fi=='-')) ans=true;
            if (e.fi=='o' && e.se==1 && r[i-1].fi=='-' && r[i+1].fi=='-' && r[i-1].se+r[i+1].se>=3) ans=true;
            if (e.fi=='-' && e.se%2==1 && r[i-1].fi=='o' && r[i+1].fi=='o') ans=true;
        }
        if (ans){
            cout<<"O\n";
        }else{
            cout<<"X\n";
        }
    }
    return 0;
}
0