結果

問題 No.226 0-1パズル
ユーザー InevitInevit
提出日時 2021-12-21 14:33:51
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 1,509 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 30,504 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-04 12:08:47
合計ジャッジ時間 1,121 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#define HWMAX 100
#define MOD 1000000007

int main(void)
{
  int i, j, h, w, res1 = 1, res2 = 1, canstartzero = 1, canstartone = 1, canzero[HWMAX], canone[HWMAX];
  char str[HWMAX][HWMAX+1];
  scanf("%d %d%*c", &h, &w);
  for (i = 0; i < h; i++) scanf("%s%*c", str[i]);
  for (i = 0; i < w; i++) canzero[i] = canone[i] = 1;
  for (i = 0; i < w; i++) {
    int hwtype = 0;
    for (j = 0; j < h; j++) {
      if (str[j][i] == '0') {
        if (j & 1) canzero[i] = 0;
        else canone[i] = 0;
      } else if (str[j][i] == '1') {
        if (j & 1) canone[i] = 0;
        else canzero[i] = 0;
      }
    }
    if (canzero[i]) hwtype++;
    if (canone[i]) hwtype++;
    res1 = res1 * hwtype % MOD;
  }
  for (i = 0; i < w; i++){
    if (i & 1) {
      if (!canzero[i]) canstartone = 0;
      if (!canone[i]) canstartzero = 0;
    } else {
      if (!canzero[i]) canstartzero = 0;
      if (!canone[i]) canstartone = 0;
    }
  }
  if (canstartzero) res1--;
  if (canstartone) res1--;
  res1 = (res1 + MOD) % MOD;
  for (i = 0; i < h; i++) canzero[i] = canone[i] = 1;
  for (i = 0; i < h; i++) {
    int hwtype = 0;
    for (j = 0; j < w; j++) {
      if (str[i][j] == '0') {
        if (j & 1) canzero[i] = 0;
        else canone[i] = 0;
      } else if (str[i][j] == '1') {
        if (j & 1) canone[i] = 0;
        else canzero[i] = 0;
      }
    }
    if (canzero[i]) hwtype++;
    if (canone[i]) hwtype++;
    res2 = res2 * hwtype % MOD;
  }
  printf("%d\n", (res1 + res2) % MOD);
}
0