結果

問題 No.3229 Liar Game Comibination
コンテスト
ユーザー tnakao0123
提出日時 2025-08-15 16:44:10
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 72 ms / 2,000 ms
+ 197µs
コード長 1,085 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 322 ms
コンパイル使用メモリ 77,272 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-14 01:30:00
合計ジャッジ時間 2,817 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

/* -*- 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