結果

問題 No.43 野球の試合
ユーザー HimatsubushinHimatsubushin
提出日時 2021-03-09 12:53:42
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,130 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 31,488 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-19 10:38:54
合計ジャッジ時間 704 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>

int check(int[7][7], int, int);

int main(int argc, const char * argv[]) {
  int i, j, n;
  int s[7][7];
  char d[7];

  scanf("%d", &n);
  for (j = 0; j < n; j++) {
    scanf("%s", d);
    for (i = 0; i < n; i++) {
      if (d[i] == '-')
        s[j][i] = 0;
      else if (d[i] == 'x')
        s[j][i] = -1;
      else if (d[i] == 'o')
        s[j][i] = 1;
      else
        s[j][i] = 9;
    }
  }

  printf("%d ", check(s, n, 1));
  printf("%d\n", check(s, n, -1));

  return EXIT_SUCCESS;
}

int check(int d[7][7], int n, int a) {
  int i, j, r = 0;
  int c[7][7], num[7] = {0, 0, 0, 0, 0, 0, 0};

  for (j = 0; j < n; j++) {
    for (i = 0; i < n; i++) {
      if (j < i) {
        if (d[j][i] == 0)
          c[j][i] = a;
        else
          c[j][i] = d[j][i];
      }
      else {
        if (d[j][i] == 0)
          c[j][i] = -1;
        else
          c[j][i] = d[j][i];
      }
    }
  }

  for (j = 0; j < n; j++) {
    for (i = 0; i < n; i++) {
      if (d[j][i] == 1)
        num[j]++;
    }
  }

  for (j = 1; j < n; j++)
    if (num[0] < num[j])
      r++;

  return r;
}
0