結果

問題 No.2255 Determinant Sum
ユーザー 👑 chro_96chro_96
提出日時 2023-03-26 01:41:13
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 1,331 bytes
コンパイル時間 348 ms
コンパイル使用メモリ 31,300 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 09:22:41
合計ジャッジ時間 1,680 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 34 ms
4,348 KB
testcase_07 AC 21 ms
4,348 KB
testcase_08 AC 21 ms
4,348 KB
testcase_09 AC 22 ms
4,348 KB
testcase_10 AC 26 ms
4,348 KB
testcase_11 AC 9 ms
4,348 KB
testcase_12 AC 13 ms
4,348 KB
testcase_13 AC 9 ms
4,348 KB
testcase_14 AC 25 ms
4,348 KB
testcase_15 AC 13 ms
4,348 KB
testcase_16 AC 14 ms
4,348 KB
testcase_17 AC 13 ms
4,348 KB
testcase_18 AC 10 ms
4,348 KB
testcase_19 AC 11 ms
4,348 KB
testcase_20 AC 13 ms
4,348 KB
testcase_21 AC 13 ms
4,348 KB
testcase_22 AC 12 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main () {
  int t = 0;
  int n = 0;
  int p = 0;
  int a[50][50] = {};
  
  int res = 0;
  
  long long b[50] = {};
  
  res = scanf("%d", &t);
  while (t > 0) {
    res = scanf("%d", &n);
    res = scanf("%d", &p);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        res = scanf("%d", a[i]+j);
      }
    }
    if (p > 2) {
      printf("0\n");
    } else {
      int bcnt = 0;
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
          if (a[i][j] < 0) {
            int cnt = 0;
            for (int k = 0; k < n; k++) {
              if (a[i][k] < 0) {
                cnt++;
              }
              a[i][k] = 0;
            }
            if (cnt == 1) {
              a[i][j] = 1;
            }
          }
        }
      }
      for (int i = 0; i < n; i++) {
        long long v = 0LL;
        for (int j = 0; j < n; j++) {
          if (a[i][j] > 0) {
            v |= (1LL<<((long long)j));
          }
        }
        for (int j = 0; j < bcnt; j++) {
          if (v > (v^b[j])) {
            v = (v^b[j]);
          }
        }
        if (v > 0) {
          b[bcnt] = v;
          bcnt++;
        }
      }
      if (bcnt == n) {
        printf("1\n");
      } else {
        printf("0\n");
      }
    }
    t--;
  }
  
  return 0;
}
0