結果

問題 No.1016 三目並べ
ユーザー keserasera_77keserasera_77
提出日時 2020-04-03 23:31:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 1,467 bytes
コンパイル時間 790 ms
コンパイル使用メモリ 92,844 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-16 04:58:22
合計ジャッジ時間 1,462 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 4 ms
4,376 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 5 ms
4,380 KB
testcase_10 AC 5 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision


#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } else return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } else return false; }

int main() {
	int t;
	cin >> t;

	rep(test, t) {
		int n; cin >> n;
		string s; cin >> s;

		bool ok = false, cntOk = false;
		int cnt = 0;
		rep(i, n) {
			if (s[i] == 'x') { cntOk = false; cnt = 0;}
			if (s[i] == 'o') { cntOk = true; if (cnt & 1) {ok = true; break; }cnt = 0; }
			if (cntOk && s[i] == '-') cnt++;
		}

		auto f = [&](string ss) { return s.find(ss) != string::npos; };

		if (f("ooo") || f("-oo") || f("oo-") || f("-o--") || f("--o-") || ok) cout << 'O' << endl;
		else cout << 'X' << endl;
	}
}
0