結果

問題 No.43 野球の試合
ユーザー aa
提出日時 2016-07-09 03:46:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 5,000 ms
コード長 923 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 45,260 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 09:10:50
合計ジャッジ時間 827 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <algorithm>

using namespace std;

char s[11][11];
int x[11], y[11], c = 0;

int main(void) {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      if (s[i][j] == '-') {
        x[c] = j;
        y[c] = i;
        c += 1;
      }
    }
  }

  int res = 111;
  for (int i = 0; i < 1<<c; i++) {
    for (int j = 0; j < c; j++) {
      s[y[j]][x[j]] = (i>>j&1) ? 'o' : 'x';
      s[x[j]][y[j]] = (i>>j&1) ? 'x' : 'o';
    }
    int pts[11]{};
    bool cnt[11]{};
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (s[j][k] == 'o') pts[j] += 1;
      }
    }

    int r = 0;
    for (int i = 1; i < n; i++) {
      if (!cnt[pts[i]] && pts[i] > pts[0]) {
        cnt[pts[i]] = 1;
        r++;
      }
    }
    res = min(res, r+1);
  }

  printf("%d\n", res);
  return 0;
}
0