結果
| 問題 |
No.1016 三目並べ
|
| コンテスト | |
| ユーザー |
kyort0n
|
| 提出日時 | 2020-04-03 21:47:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,481 bytes |
| コンパイル時間 | 1,680 ms |
| コンパイル使用メモリ | 171,200 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-03 02:02:42 |
| 合計ジャッジ時間 | 2,081 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 10 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
if(a < b) {
a = b;
return true;
}
return false;
}
template<class T>
inline bool chmin(T &a, T b) {
if(a > b) {
a = b;
return true;
}
return false;
}
const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
bool check(string S) {
//cerr << S << endl;
ll num = 0;
for(int i = 0; i < S.size(); i++) {
if(S[i] == 'o') num++;
}
if(num >= 3) return true;
if(num == 0) return false;
if(num == 1) {
if(S.size() <= 3 or S.back() == 'o' or S[0] == 'o') return false;
return true;
}
if((int)S.size() % 2 == 0 and S[0] == 'o' and S.back() == 'o') return false;
return true;
}
void solve() {
ll N;
string S;
cin >> N >> S;
S = "x" + S + "x";
ll Last = 0;
//cerr << S << endl;
for(int i = 1; i < S.size(); i++) {
if(S[i] == 'x') {
if(i - Last - 1 > 0 and check(S.substr(Last+1, i-Last-1))) {
cout << "O" << endl;
return;
}
Last = i;
}
}
cout << "X" << endl;
}
int main() {
//cout.precision(10);
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
while(N--) solve();
return 0;
}
kyort0n