結果

問題 No.1016 三目並べ
ユーザー RubikunRubikun
提出日時 2020-04-03 21:56:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,250 bytes
コンパイル時間 1,585 ms
コンパイル使用メモリ 167,988 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-16 01:19:16
合計ジャッジ時間 2,139 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;
vector<string> win={"ooo","--o-","-o--","-oo","oo-","o-o"};

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int Q;cin>>Q;
    while(Q--){
        int N;string S;cin>>N>>S;
        bool ok=false;
        
        for(int i=0;i<N;i++){
            for(int j=0;j<6;j++){
                bool check=true;
                if(i+win[j].size()>N) continue;
                
                for(int k=0;k<win[j].size();k++){
                    if(S[i+k]!=win[j][k]) check=false;
                }
                
                if(check) ok=true;
            }
        }
        
        int i=0;
        while(i<N){
            while(i<N&&S[i]!='o') i++;
            if(i>=N) break;
            int j=i+1;
            while(j<N&&S[j]=='-') j++;
            if(j>=N) break;
            if(S[j]!='o'){
                i=j;
                continue;
            }
            
            if((j-i)%2==0) ok=true;
            i=j;
        }
        
        if(ok) cout<<"O\n";
        else cout<<"X\n";
    }
}

0