結果

問題 No.43 野球の試合
ユーザー a
提出日時 2016-07-09 03:42:34
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 870 bytes
コンパイル時間 317 ms
コンパイル使用メモリ 42,880 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-13 08:03:54
合計ジャッジ時間 851 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 4 WA * 3
権限があれば一括ダウンロードができます

ソースコード

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]] = s[x[j]][y[j]] = (i>>j&1) ? 'o' : 'x';
    }
    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]) {
        r++;
      }
    }
    res = min(res, r+1);
  }

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