結果

問題 No.1016 三目並べ
ユーザー MayimgMayimg
提出日時 2020-04-05 20:51:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 969 bytes
コンパイル時間 1,953 ms
コンパイル使用メモリ 199,488 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-17 05:47:16
合計ジャッジ時間 2,633 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  auto solve = [] () {
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 0; i + 2 < n; i++) {
      if (s.substr(i, 3) == "ooo") return "O\n";
    }
    for (int i = 0; i < n; i++) {
      if (s[i] == '-') {
        s[i] = 'o';
        for (int j = max(0, i - 2); j <= i; j++) {
          if (s.substr(j, 3) == "ooo") return "O\n";
        }
        for (int j = max(0, i - 3); j <= i; j++) {
          if (s.substr(j, 4) == "-oo-") return "O\n";
        }
        s[i] = '-';
      }
    }
    bool f = false;
    int p = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] == 'o') {
        if (f && (i - p) > 0 && (i - p) % 2 == 0) return "O\n";
        f = true;
        p = i;
      }
      if (s[i] == 'x') f = false;
    }
    return "X\n";
  };
  int t;
  cin >> t;
  while (t--) cout << solve();
  return 0;
}
0