結果

問題 No.1016 三目並べ
ユーザー cureskolcureskol
提出日時 2020-04-03 21:43:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 917 bytes
コンパイル時間 1,469 ms
コンパイル使用メモリ 169,968 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-16 00:44:27
合計ジャッジ時間 2,102 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

vector<char> ans;

signed main(){
  int t;cin>>t;
  while(t--){
    bool ok=0;
    int n;string s;cin>>n>>s;
    if(n<3){ans.push_back('X');continue;}
    int cnt=0;
    for(int i=0;i<n;i++){
      if(s[i]=='o'){
        if(++cnt>=3)ok=1;
      }
      else cnt=0;
    }
    if(ok){ans.push_back('O');continue;}
    for(int i=0;i<n-2;i++)if(s.substr(i,3)=="oo-"||s.substr(i,3)=="o-o"||s.substr(i,3)=="-oo")ok=1;
    if(ok){ans.push_back('O');continue;}
    int start=0,odd=0;
    for(int i=1;i<n-1;i++){
      if(s[i]=='-'&&(!start)&&s[i-1]=='o'){
        start=1;
        odd=1;
        continue;
      }
      if(s[i]=='-'&&start)odd^=1;
      if(s[i]=='o'&&start){
        if(odd)ok=1;
        start=0;
      }
      if(s[i]=='x'&&start){
        start=0;
      }
    }
    if(ok)ans.push_back('O');
    else ans.push_back('X');
  }
  for(char p:ans)cout<<p<<endl;
}
0