結果

問題 No.1016 三目並べ
ユーザー penguinman_2ndpenguinman_2nd
提出日時 2020-04-03 21:52:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,536 bytes
コンパイル時間 1,658 ms
コンパイル使用メモリ 174,312 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-16 01:08:27
合計ジャッジ時間 3,905 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
pii func(int N,string S){
  vi A(N);
  int cnt=0;
  rep(i,0,N){
    A[i]=cnt;
    if(S[i]=='o') cnt++;
    else cnt=0;
  }
  cnt=0;
  REP(j,1,N){
    int i=N-j;
    A[i]=max(cnt,A[i]);
    if(S[i]=='o') cnt++;
    else cnt=0;
  }
  vector<pii> B;
  rep(i,0,N){
    if(S[i]=='-') B.pb(mp(A[i],i));
  }
  sort(ALL(B),greater<pii>());
  return B[0];
}
signed main(){
  int T; cin>>T;
  rep(_,0,T){
    int N; string S; cin>>N>>S;
    int cnt=0,sum=0;
    bool flag=1;
    rep(i,0,N){
      if(S[i]=='o'){
        cnt++;
        if(cnt>=3) flag=0;
      }
      else{
        cnt=0;
        if(S[i]=='-') sum++;
      }
    }
    char ans='X';
    if(flag){
      rep(i,0,sum){
        auto p=func(N,S);
        if(i%2==0&&p.first==2){
          ans='O';
          break;
        }
        if(i%2==0) S[p.second]='o';
        else S[p.second]='x';
      }
    }
    else ans='O';
    cout<<ans<<endl;
  }
  }

0