結果

問題 No.1016 三目並べ
ユーザー 沙耶花沙耶花
提出日時 2020-04-03 21:54:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,051 bytes
コンパイル時間 1,916 ms
コンパイル使用メモリ 201,308 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-16 01:14:11
合計ジャッジ時間 3,039 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘bool check(std::string&)’ 内:
main.cpp:26:1: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type]
   26 | }
      | ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)
#define Inf 1000000000000

bool check(string &S){
	char c = 'x';
	int last = -1;
	for(int i=0;i<S.size();i++){
		if(S[i]=='x'){
			c='x';
		}
		else if(S[i]=='o'){
			if(c=='o'){
				int gap = i-last;
				if(gap%2==0)return true;
				else{
					if(i!=S.size()-1&&S[i+1]=='-')return true;
				}
			}
			last=i;
			c='o';
		}
	}
}

int main() {

	int T;
	cin>>T;
	
	for(int _=0;_<T;_++){
		int N;
		cin>>N;
		
		string S;
		cin>>S;
		
		bool f = false;
		if(S.size()>=3){
			for(int i=0;i<S.size()-2;i++){
				string s = S.substr(i,3);
				if(s=="ooo"||s=="o-o"||s=="oo-"||s=="-oo"){
					f=true;
					break;
				}
			}
		}
		
		if(S.size()>=4){
			for(int i=0;i<S.size()-3;i++){
				string s = S.substr(i,4);
				if(s=="-o--"||s=="--o-"){
					f=true;
					break;
				}
			}
		}
		
		if(check(S))f=true;
		reverse(S.begin(),S.end());
		if(check(S))f=true;
		if(f)cout<<"O"<<endl;
		else cout<<"X"<<endl;
	}
	
    return 0;
}
0