結果

問題 No.1016 三目並べ
ユーザー sarah Lewissarah Lewis
提出日時 2020-12-31 12:14:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 829 bytes
コンパイル時間 1,418 ms
コンパイル使用メモリ 170,016 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-17 17:28:46
合計ジャッジ時間 2,584 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 WA -
testcase_02 AC 1 ms
6,944 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 WA -
testcase_08 AC 7 ms
6,940 KB
testcase_09 AC 8 ms
6,940 KB
testcase_10 AC 10 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a) for(auto &i:a)
using namespace std;
using ll = long long;
const ll mod = 1000000007;

#define yes "O"
#define no "X"
int N;
string S;

string solve() {
  cin >> N >> S;

  vector<string> wins = {"ooo", "oo-", "-oo", "--o-", "-o--"};
  fore (win, wins) rep (i, 0, N) if (S.substr(i, win.size()) == win) return yes;

  vector<int> okvec;
  rep (i, 0, N) if (S[i] == 'o') okvec.push_back(i);

  int r = okvec.size();
  rep (i, 0, r) {
    int s = okvec[i];
    int e = okvec[i + 1];
    int lose = 0;
    int blank = 0;
    rep (j, s + 1, e) {
      if (S[j] == 'x') lose++;
      else blank++;
    }
    if (lose == 0 && blank % 2 == 1) return yes;
  }
    return no;
}

int main() {
  int T;
  cin >> T;
  rep (i, 0, T) cout << solve() << endl;
}
0