結果

問題 No.3229 Liar Game Comibination
ユーザー tnakao0123
提出日時 2025-08-15 16:44:10
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 1,085 bytes
コンパイル時間 920 ms
コンパイル使用メモリ 67,420 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-08-15 16:44:15
合計ジャッジ時間 5,055 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:42:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   42 |   scanf("%d%d%d", &n, &m, &k);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:45:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   45 |     scanf("%s", s);
      |     ~~~~~^~~~~~~~~

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 3229.cc:  No.3229 Liar Game Comibination - yukicoder
 */

#include<cstdio>
#include<bitset>
#include<algorithm>

using namespace std;

/* constant */

const int MAX_N = 2560;
const int MAX_M = 2560;

/* typedef */

using ll = long long;
using btst = bitset<MAX_N>;

/* global variables */

btst bs[MAX_M];

/* subroutines */

int powmod(int a, int b, int mod) {
  int p = 1;
  while (b > 0) {
    if (b & 1) p = (ll)p * a % mod;
    a = (ll)a * a % mod;
    b >>= 1;
  }
  return p;
}

/* main */

int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < m; i++) {
    char s[MAX_N + 4];
    scanf("%s", s);
    bs[i] = btst(s);
  }

  int i0 = 0;
  for (int j = 0; j < n && i0 < m; j++) {
    if (! bs[i0][j]) {
      int i1 = i0 + 1;
      while (i1 < m && ! bs[i1][j]) i1++;
      if (i1 >= m) continue;
      swap(bs[i0], bs[i1]);
    }

    for (int i1 = i0 + 1; i1 < m; i1++)
      if (bs[i1][j]) bs[i1] ^= bs[i0];
    i0++;
  }
  //printf(" n=%d, i0=%d\n", n, i0);

  printf("%d\n", powmod(2, n - i0, k));
  
  return 0;
}
0