Submission #1007112


Source Code Expand

#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int MAX = 303;
const int mod = 1e9 + 7;

inline int add(int a, int b) {
  return a+b >= mod ? a+b-mod : a+b;
}

inline int sub(int a, int b) {
  return a >= b ? a-b : a-b+mod;
}

inline int mul(int a, int b) {
  return llint(a)*b % mod;
}

int c[MAX][MAX];
int f[MAX][MAX][MAX];
int pw[MAX*MAX];

int main(void) {
  int N;
  scanf("%d", &N);
  REP(i, N) REP(j, N) scanf("%d", &c[i][j]);


  int r = 0;
  REP(i, N) {
    int k = -1;
    FOR(j, r, N)
      if (c[j][i]) { k = j; break; }
    if (k == -1) continue;
      
    REP(j, N) swap(c[r][j], c[k][j]);
    REP(j, N)
      if (j != r && c[j][i])
        REP(k, N) c[j][k] ^= c[r][k];
    r++;
  }

  pw[0] = 1;
  FOR(i, 1, MAX*MAX) pw[i] = mul(pw[i-1], 2);
  
  f[0][0][0] = 1;
  REP(i, N) REP(rc, min(i+1, r+1)) REP(rn, min(i+1-rc, N-r+1)) {
    f[i+1][rc][rn] = add(f[i+1][rc][rn], mul(pw[rc+rn], f[i][rc][rn]));
    if (rc < r) {
      f[i+1][rc+1][rn] = add(f[i+1][rc+1][rn], mul(sub(pw[r+rn], pw[rc+rn]), f[i][rc][rn]));
    }
    if (rn < N-r) {
      f[i+1][rc][rn+1] = add(f[i+1][rc][rn+1], mul(sub(pw[N], pw[r+rn]), f[i][rc][rn]));
    }
  }

  int ans = 0;
  REP(rn, N-r+1) ans = add(ans, mul(pw[N*(N-rn-r)], f[N][r][rn]));
  printf("%d\n", ans);
  return 0;
}

Submission Info

Submission Time
Task H - AB=C Problem
User ikatanic
Language C++14 (GCC 5.4.1)
Score 1500
Code Size 1589 Byte
Status AC
Exec Time 144 ms
Memory 55552 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:36:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &N);
                  ^
./Main.cpp:37:44: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   REP(i, N) REP(j, N) scanf("%d", &c[i][j]);
                                            ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1500 / 1500
Status
AC × 2
AC × 42
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt AC 3 ms 640 KB
001.txt AC 3 ms 640 KB
002.txt AC 3 ms 640 KB
003.txt AC 3 ms 640 KB
004.txt AC 3 ms 640 KB
005.txt AC 3 ms 640 KB
006.txt AC 3 ms 640 KB
007.txt AC 3 ms 640 KB
008.txt AC 3 ms 640 KB
009.txt AC 3 ms 640 KB
010.txt AC 3 ms 640 KB
011.txt AC 3 ms 640 KB
012.txt AC 3 ms 640 KB
013.txt AC 3 ms 640 KB
014.txt AC 21 ms 8960 KB
015.txt AC 15 ms 4992 KB
016.txt AC 9 ms 3200 KB
017.txt AC 10 ms 2048 KB
018.txt AC 6 ms 1920 KB
019.txt AC 4 ms 640 KB
020.txt AC 33 ms 12672 KB
021.txt AC 135 ms 45312 KB
022.txt AC 5 ms 1408 KB
023.txt AC 59 ms 15744 KB
024.txt AC 130 ms 55552 KB
025.txt AC 134 ms 42368 KB
026.txt AC 144 ms 50048 KB
027.txt AC 116 ms 34816 KB
028.txt AC 31 ms 7168 KB
029.txt AC 138 ms 44672 KB
030.txt AC 142 ms 48640 KB
031.txt AC 129 ms 40064 KB
032.txt AC 16 ms 3072 KB
033.txt AC 143 ms 52608 KB
034.txt AC 14 ms 2304 KB
035.txt AC 10 ms 1920 KB
036.txt AC 120 ms 55552 KB
037.txt AC 102 ms 47616 KB
038.txt AC 20 ms 4096 KB
039.txt AC 117 ms 53760 KB
example0.txt AC 3 ms 640 KB
example1.txt AC 3 ms 768 KB