結果

問題 No.1016 三目並べ
ユーザー queee
提出日時 2020-04-03 21:53:48
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 1,047 bytes
コンパイル時間 758 ms
コンパイル使用メモリ 80,156 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-03 02:20:33
合計ジャッジ時間 1,339 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>

using namespace std; typedef long long ll;
typedef pair<int,int> P; const int INF = 1e9+1;
int main() {
  int t; cin>>t;
  for(int i=0;i<t;i++) {
    int n; string s; cin>>n>>s;
    if (n<3) {cout<<"X"<<endl; continue;}
    bool ok=false;
    for(int i=0;i<n;i++) {
      if (i<n-2){
        if (s[i]=='o' && s[i+1]=='o' && s[i+2]=='o') ok=true;
        if (s[i]=='-' && s[i+1]=='o' && s[i+2]=='o') ok=true;
        if (s[i]=='o' && s[i+1]=='-' && s[i+2]=='o') ok=true;
        if (s[i]=='o' && s[i+1]=='o' && s[i+2]=='-') ok=true;
      }
      if (i<n-3){
        if (s[i]=='-' && s[i+1]=='o' && s[i+2]=='-'&& s[i+3]=='-') ok=true;
        if (s[i]=='-' && s[i+1]=='-' && s[i+2]=='o'&& s[i+3]=='-') ok=true;
      }
    }
    for(int i=0;i<n-1;i++) {
      if (s[i]=='o') {
        i++; int hw=0;
        while(i<n && s[i]=='-') hw++,i++;
        if (s[i]=='o' && hw%2) ok=true;
      }
    }
    if (ok) cout<<"O"<<endl;
    else cout<<"X"<<endl;
  }
}
0