Problem:


Score : 800 points

Problem Statement

There is a square grid with N rows and M columns.
Each square contains an integer: 0 or 1. The square at the i-th row from the top and the j-th column from the left contains a_{ij}.

Among the 2^{N+M} possible pairs of a subset A of the rows and a subset B of the columns, find the number of the pairs that satisfy the following condition, modulo 998244353:

The sum of the |A||B| numbers contained in the intersection of the rows belonging to A and the columns belonging to B, is odd.

Constraints

1 \leq N,M \leq 300

0 \leq a_{i,j} \leq 1(1\leq i\leq N,1\leq j\leq M)

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
a_{11} ... a_{1M}
:
a_{N1} ... a_{NM}

Output

Print the number of the pairs of a subset of the rows and a subset of the columns that satisfy the condition, modulo 998244353.

Sample Input 1

2 2
0 1
1 0

Sample Output 1

6

For example, if A consists of the first row and B consists of both columns, the sum of the numbers contained in the intersection is 0+1=1.

Sample Input 2

2 3
0 0 0
0 1 0

Sample Output 2

8



Sample input:
2 2
0 1
1 0


Sample output:
6

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]

mod = 998244353

for i in range(n):
    for j in range(m):
        a[i][j] = a[i][j] % 2

# 掃き出し法
rank = 0
for i in range(n):
    target = -1
    for j in range(rank, m):
        if a[i][j]:
            target = j
            break

    if target == -1:
        continue

    if target != rank:
        for i in range(rank, n):
            a[i][rank], a[i][target] = a[i][target], a[i][rank]

    for k in range(rank+1, n):
        if a[k][rank]:
            for j in range(rank, m):
                a[k][j] -= a[rank][j]

    rank += 1


def modpow(a, n, mod=mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res

print(modpow(2, m-1) * (modpow(2, n) - modpow(2, n-rank) % mod))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]

mod = 998244353

for i in range(n):
    for j in range(m):
        a[i][j] = a[i][j] % 2

# 掃き出し法
rank = 0
for i in range(n):
    target = -1
    for j in range(rank, m):
        if a[i][j]:
            target = j
            break

    if target == -1:
        continue

    if target != rank:
        for i in range(rank, n):
            a[i][rank], a[i][target] = a[i][target], a[i][rank]

    for i in range(rank+1, n):
        if a[i][rank]:
            for j in range(rank, m):
                a[i][j] -= a[rank][j]

    rank += 1


def modpow(a, n, mod=mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res

print(modpow(2, m-1) * (modpow(2, n) - modpow(2, n-rank) % mod) )

Submission status: Wrong Answer

Solution code:
import numpy as np
MOD = 998244353
n, m = map(int, input().split())
a = np.array([list(map(int, input().split())) for _ in [0]*n])
#a[:, [0, 1]] = a[:, [1, 0]]
#print(a)
r = 0
for i in range(min(m, n)):
	if a[i][i] != 1:
		for j in range(i+1, m):
			if a[i][j] == 1:
				a[:, [i, j]] = a[:, [j, i]]
				break
		else:
			for j in range(i+1, n):
				if a[j][i] == 1:
					a[[i, j]] = a[j, i]
				break
			else:
				break
	if a[i][i] == 0:
		continue

	r += 1
	for j in range(i+1, m):
		a[:, j] -= a[i][j] * a[:, i]
		a[:, j] %= 2
	for j in range(i+1, n):
		a[j] -= a[j][i] * a[i]
		a[j] %= 2

#print(r)
print((pow(2, n+m-1, MOD) - pow(2, n+m-r-1, MOD)) % MOD)

Submission status: Wrong Answer

Solution code:
# from : https://atcoder.jp/contests/yahoo-procon2019-qual/submissions/4212377
H,W = map(int, input().split())
A = [ [int(j) for j in input().split()] for _ in range(H)]
MOD = 998244353

piv = 0

# Gaussian Elimination to calculate rank of the matrix A
for w in range(W): # fix column, 
    r = -1
    for h in range(piv, H):
        if A[h][w] == 1:
            r = h
            break
    if r == -1: # there is no odd cell for all the rows inside intersections.
        continue 

    # You want to set ODD ROW ( A[h][w] == 1 ) into pivot row.
    if r != piv: # already, skip.
        for j in range(W): # swap rows
            A[r][j], A[piv][j] = A[piv][j], A[r][j]

    # for h in 
    for h in range(H):
        if h != piv and A[h][w] == 1: # really needed?
            # for j in range(W):
            for k in range(h, W):
                A[h][k] ^= A[piv][k]
                # A[h][j] ^= A[piv][j] # for other rows, erase ...
                # Hakidashi method: http://senkei.nomaki.jp/gaussian_elimination.html
                # https://ja.wikipedia.org/wiki/%E3%82%AC%E3%82%A6%E3%82%B9%E3%81%AE%E6%B6%88%E5%8E%BB%E6%B3%95 : Gaussian Elimination
    piv += 1


# print("----output matrix ----")
# for h in range(H):
#     print(A[h])
# exit(0)


# from pprint import pprint; pprint(A)

ret = 1
ret = pow(2, H, MOD)
# for h in range(H):
#     ret = ret * 2 % MOD

sub = 1
# for i in range(H-piv):
#     sub = sub * 2 % MOD
sub = pow(2, H-piv, MOD)


ret += MOD - sub          # ret = 2^N - 2^(N-r)
ret %= MOD

for i in range(W-1):      # ret *= 2^(M-1)
    ret = ret * 2 % MOD

# from editorial  : https://img.atcoder.jp/yahoo-procon2019-qual/editorial.pdf
# rank : r 
# 2^(N+M-1) - 2^(N+M-r-1)

print(ret % MOD)

Submission status: Wrong Answer

Solution code:
# from : https://atcoder.jp/contests/yahoo-procon2019-qual/submissions/4212377
H,W = map(int, input().split())
A = [ [int(j) for j in input().split()] for _ in range(H)]
MOD = 998244353

piv = 0
for w in range(W): # fix column, 
    r = -1
    for h in range(piv, H):
        if A[h][w] == 1:
            r = h
            break
    if r == -1: # there is no odd cell for all the rows inside intersections.
        continue 

    # You want to set ODD ROW ( A[h][w] == 1 ) into pivot row.
    if r != piv: # already, skip.
        for w in range(W): # swap rows
            A[r][w], A[piv][w] = A[piv][w], A[r][w]

    for h in range(H):
        if h != piv and A[h][w] == 1: # really needed?
            for k in range(h, W):
                A[h][k] ^= A[piv][k] # for other rows, erase ...
                # Hakidashi method: http://senkei.nomaki.jp/gaussian_elimination.html
                # https://ja.wikipedia.org/wiki/%E3%82%AC%E3%82%A6%E3%82%B9%E3%81%AE%E6%B6%88%E5%8E%BB%E6%B3%95 : Gaussian Elimination
    piv += 1


# from pprint import pprint; pprint(A)

ret = 1
ret = pow(2, H, MOD)
# for h in range(H):
#     ret = ret * 2 % MOD

sub = 1
# for i in range(H-piv):
#     sub = sub * 2 % MOD
sub = pow(2, H-piv, MOD)


ret += MOD - sub          # ret = 2^N - 2^(N-r)
ret %= MOD

for i in range(W-1):      # ret *= 2^(M-1)
    ret = ret * 2 % MOD

# from editorial  : https://img.atcoder.jp/yahoo-procon2019-qual/editorial.pdf
# rank : r 
# 2^(N+M-1) - 2^(N+M-r-1)

print(ret % MOD)

Submission status: Wrong Answer

Solution code:
# from : https://atcoder.jp/contests/yahoo-procon2019-qual/submissions/4212377
N,M = map(int, input().split())
A = [ [int(j) for j in input().split()] for _ in range(N)]
MOD = 998244353


import numpy as np
npA = np.array(A)
rank = np.linalg.matrix_rank(npA)
rank = rank.item()

# ret = 1
# for h in range(H):
#     ret = ret * 2 % MOD
# sub = 1
# for i in range(H-rank):
#     sub = sub * 2 % MOD
# ret = (ret+ MOD  - sub) % MOD
# 
# for w in range(W-1):
#     ret = ret * 2 % MOD

# from editorial  : https://img.atcoder.jp/yahoo-procon2019-qual/editorial.pdf
# rank : r 
# 2^(N+M-1) - 2^(N+M-r-1)

print ( (pow(2,(N+M-1),MOD) - pow(2,(N+M-rank-1),  MOD))%MOD ) 
# print(ret % MOD)

Submission status: Wrong Answer

Solution code:
# from : https://atcoder.jp/contests/yahoo-procon2019-qual/submissions/4212377
N,M = map(int, input().split())
A = [ [int(j) for j in input().split()] for _ in range(N)]
MOD = 998244353


import numpy as np
npA = np.array(A)
rank = np.linalg.matrix_rank(npA)

# ret = 1
# for h in range(H):
#     ret = ret * 2 % MOD
# sub = 1
# for i in range(H-rank):
#     sub = sub * 2 % MOD
# ret = (ret+ MOD  - sub) % MOD
# 
# for w in range(W-1):
#     ret = ret * 2 % MOD

# from editorial  : https://img.atcoder.jp/yahoo-procon2019-qual/editorial.pdf
# rank : r 
# 2^(N+M-1) - 2^(N+M-r-1)

print ( (2**(N+M-1) - 2**(N+M-rank-1))%MOD ) 
# print(ret % MOD)

Submission status: Wrong Answer

Solution code:
# from : https://atcoder.jp/contests/yahoo-procon2019-qual/submissions/4212377
H,W = map(int, input().split())
A = [ [int(j) for j in input().split()] for _ in range(H)]
MOD = 998244353


import numpy as np
npA = np.array(A)
rank = np.linalg.matrix_rank(npA)

ret = 1
for h in range(H):
    ret = ret * 2 % MOD
sub = 1
for i in range(H-rank):
    sub = sub * 2 % MOD
ret = (ret+ MOD  - sub) % MOD

for w in range(W-1):
    ret = ret * 2 % MOD

# from editorial  : https://img.atcoder.jp/yahoo-procon2019-qual/editorial.pdf
# rank : r 
# 2^(N+M-1) - 2^(N+M-r-1)

print(ret % MOD)

Submission status: Wrong Answer

Solution code:
# from : https://atcoder.jp/contests/yahoo-procon2019-qual/submissions/4212377
H,W = map(int, input().split())
A = [ [int(j) for j in input().split()] for _ in range(H)]
MOD = 998244353

piv = 0
for w in range(W): # fix column, 
    r = -1
    for h in range(piv, H):
        if A[h][w] == 1:
            r = h
            break
    if r == -1: # there is no odd cell for all the rows inside intersections.
        continue 

    # You want to set ODD ROW ( A[h][w] == 1 ) into pivot row.
    if r != piv: # already, skip.
        for w in range(W): # swap rows
            A[r][w], A[piv][w] = A[piv][w], A[r][w]
    else:
        continue

    for h in range(H):
        if h != piv and A[h][w] == 1: # really needed?
            for k in range(h, W):
                A[h][k] ^= A[piv][k] # for other rows, erase ...
                # Hakidashi method: http://senkei.nomaki.jp/gaussian_elimination.html
                # https://ja.wikipedia.org/wiki/%E3%82%AC%E3%82%A6%E3%82%B9%E3%81%AE%E6%B6%88%E5%8E%BB%E6%B3%95 : Gaussian Elimination
    piv += 1


# from pprint import pprint; pprint(A)

ret = 1
for h in range(H):
    ret = ret * 2 % MOD

sub = 1
for i in range(H-piv):
    sub = sub * 2 % MOD

ret += MOD - sub          # ret = 2^N - 2^(N-r)

ret %= MOD
for i in range(W-1):      # ret *= 2^(M-1)
    ret = ret * 2 % MOD

# from editorial  : https://img.atcoder.jp/yahoo-procon2019-qual/editorial.pdf
# rank : r 
# 2^(N+M-1) - 2^(N+M-r-1)

print(ret % MOD)

Submission status: Wrong Answer

Solution code:
# from : https://atcoder.jp/contests/yahoo-procon2019-qual/submissions/4212377
H,W = map(int, input().split())
A = [ [int(j) for j in input().split()] for _ in range(H)]
MOD = 998244353

piv = 0
for w in range(W): # fix column, 
    r = -1
    for h in range(piv, H):
        if A[h][w] == 1:
            r = h
            break
    if r == -1: # there is no odd cell for all the rows inside intersections.
        continue 

    # You want to set ODD ROW ( A[h][w] == 1 ) into pivot row.
    if r != piv: # already, skip.
        for w in range(W): # swap rows
            A[r][w], A[piv][w] = A[piv][w], A[r][w]

    for h in range(H):
        if h != piv and A[h][w] == 1: # really needed?
            for k in range(h, W):
                A[h][k] ^= A[piv][k] # for other rows, erase ...
                # Hakidashi method: http://senkei.nomaki.jp/gaussian_elimination.html
                # https://ja.wikipedia.org/wiki/%E3%82%AC%E3%82%A6%E3%82%B9%E3%81%AE%E6%B6%88%E5%8E%BB%E6%B3%95 : Gaussian Elimination
    piv += 1


# from pprint import pprint; pprint(A)

ret = 1
for h in range(H):
    ret = ret * 2 % MOD

sub = 1
for i in range(H-piv):
    sub = sub * 2 % MOD

ret += MOD - sub          # ret = 2^N - 2^(N-r)

ret %= MOD
for i in range(W-1):      # ret *= 2^(M-1)
    ret = ret * 2 % MOD

# from editorial  : https://img.atcoder.jp/yahoo-procon2019-qual/editorial.pdf
# rank : r 
# 2^(N+M-1) - 2^(N+M-r-1)

print(ret % MOD)

Submission status: Wrong Answer

Solution code:
# from : https://atcoder.jp/contests/yahoo-procon2019-qual/submissions/4212377
H,W = map(int, input().split())
A = [ [int(j) for j in input().split()] for _ in range(H)]
MOD = 998244353

piv = 0
for w in range(W): # fix column, 
    r = -1
    for h in range(piv, H):
        if A[h][w] == 1:
            r = h
            break
    if r == -1: # there is no odd cell for all the rows inside intersections.
        continue 

    # You want to set ODD ROW ( A[h][w] == 1 ) into pivot row.
    if r != piv: # already, skip.
        for w in range(W): # swap rows
            A[r][w], A[piv][w] = A[piv][w], A[r][w]

    for h in range(H):
        if h != piv and A[h][w] == 1:
            for k in range(h, W):
                A[h][k] ^= A[piv][k] # for other rows, erase ...
                # Hakidashi method: http://senkei.nomaki.jp/gaussian_elimination.html
                # https://ja.wikipedia.org/wiki/%E3%82%AC%E3%82%A6%E3%82%B9%E3%81%AE%E6%B6%88%E5%8E%BB%E6%B3%95 : Gaussian Elimination
    piv += 1


# from pprint import pprint; pprint(A)

ret = 1
for h in range(H):
    ret = ret * 2 % MOD

sub = 1
for i in range(H-piv):
    sub = sub * 2 % MOD

ret += MOD - sub          # ret = 2^N - 2^(N-r)

ret %= MOD
for i in range(W-1):      # ret *= 2^(M-1)
    ret = ret * 2 % MOD

# from editorial  : https://img.atcoder.jp/yahoo-procon2019-qual/editorial.pdf
# rank : r 
# 2^(N+M-1) - 2^(N+M-r-1)

print(ret)

Submission status: Wrong Answer

Solution code:
import numpy as np

n,m = map(int, input().split())
A = np.array([ list(map(int, input().split())) for _ in range(n) ])
r = np.linalg.matrix_rank(A)
print(((2**n - 2**(n-r))*(2**(m-1))) % 998244353)

Submission status: Wrong Answer

Solution code:
import numpy as np

n,m = map(int, input().split())
A = np.array([ list(map(int, input().split())) for _ in range(n) ])
r = np.linalg.matrix_rank(A)
print(((2**n - 2**(n-r))*2**(m-1)) % 998244353)

Submission status: Wrong Answer

Solution code:
import numpy as np

n,m = map(int, input().split())
A = np.array([ list(map(int, input().split())) for _ in range(n) ])
r = np.linalg.matrix_rank(A)
print((2**n - 2**(n-r))*2**(m-1))

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys

mod = 998244353
n,m = list(map(int, input().split()))
s = max(n,m)
mat = np.zeros((s,s))

for i in range(n):
    l = list(map(int, input().split()))
    for j in range(m):
      mat[i,j] = l[j]
    
r = np.linalg.matrix_rank(mat)

ans = (pow(2,n+m-1) - pow(2,n+m-r-1)) % mod
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys

mod = 998244353
n,m = list(map(int, input().split()))
mat = np.zeros((n,m))

for i in range(n):
    l = list(map(int, input().split()))
    for j in range(m):
      mat[i,j] = l[j]
    
r = np.linalg.matrix_rank(mat)

ans = (pow(2,n+m-1,mod) - pow(2,n+m-r-1,mod) + mod) % mod
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

mod = 998244353
n,m = list(map(int, input().split()))
mat = np.zeros((n,m))

for i in range(n):
    l = list(map(int, input().split()))
    for j in range(m):
      mat[i,j] = l[j]
    
r = np.linalg.matrix_rank(mat)

ans = (pow(2,n+m-1) - pow(2,n+m-r-1)) % mod
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

mod = 998244353
n,m = list(map(int, input().split()))
mat = np.zeros((n,m))

for i in range(n):
    l = list(map(int, input().split()))
    for j in range(m):
      mat[i,j] = l[j]
    
r = np.linalg.matrix_rank(mat)

ans = (pow(2,n+m-1,mod) - pow(2,n+m-r-1,mod) + mod*mod) % mod
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

mod = 998244353
n,m = list(map(int, input().split()))
mat = np.zeros((n,m))

for i in range(n):
    l = list(map(int, input().split()))
    for j in range(m):
      mat[i,j] = l[j]
    
r = np.linalg.matrix_rank(mat)

ans = (pow(2,m-1,mod) * ((pow(2,n,mod) - pow(2,n-r,mod + mod*mod)) % mod)) % mod
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

mod = 998244353

while True:
    try:
        n,m = map(long, raw_input().split())

        mat = np.zeros((n,m))

        for i in range(n):
            mat[i] = map(long, raw_input().split())
        
        r = np.linalg.matrix_rank(mat)

        ans = (pow(2,m-1,mod) * ((pow(2,n,mod) - pow(2,n-r,mod)) % mod)) % mod
        print ans
    except:
        break

Submission status: Wrong Answer

Solution code:
import numpy as np

mod = 998244353

while True:
    try:
        n,m = map(int, raw_input().split())

        mat = np.zeros((n,m))

        for i in range(n):
            mat[i] = map(int, raw_input().split())
        
        r = np.linalg.matrix_rank(mat)

        ans = (pow(2,m-1,mod) * ((pow(2,n,mod) - pow(2,n-r,mod)) % mod)) % mod
        print ans
    except:
        break

Submission status: Wrong Answer

Solution code:
import numpy as b,sys;(n,m),*a=[list(map(int,s.split()))for s in sys.stdin];n+=m-1;print((2**n-pow(2,int(n-b.linalg.matrix_rank(a))))%998244353)

Submission status: Wrong Answer

Solution code:
import numpy as b,sys;(n,m),*a=[list(map(int,s.split()))for s in sys.stdin];n+=m-1;print((2**n-2**int(n-b.linalg.matrix_rank(a,0)))%998244353)

Submission status: Wrong Answer

Solution code:
import numpy as b,sys;(n,m),*a=[list(map(int,s.split()))for s in sys.stdin];n+=m-1;print((2**n-2**int(n-b.linalg.matrix_rank(a)))%998244353)

Submission status: Wrong Answer

Solution code:
import numpy as b,sys;(n,m),*a=[list(map(int,s.split()))for s in sys.stdin];o=998244353;n+=m-1;print((pow(2,n,o)-pow(2,n-b.linalg.matrix_rank(a,0),o))%o)

Submission status: Wrong Answer

Solution code:
import numpy as b,sys;(n,m),*a=[list(map(int,s.split()))for s in sys.stdin];o=998244353;n+=m-1;print((pow(2,n,o)-pow(2,n-b.linalg.matrix_rank(a),o))%o)

Submission status: Wrong Answer

Solution code:
import numpy as b,sys;(n,m),*a=[map(int,s.split())for s in sys.stdin];o=998244353;n+=m-1;print((pow(2,n,o)-pow(2,n-b.linalg.matrix_rank(a),o))%o)

Submission status: Wrong Answer

Solution code:
import numpy as np

mod = 998244353

def modpow(x, n):
    if(n==0):
        return 1
    else:
        return (modpow(x, n-1)*x) % mod

n,m = map(int, input().split())
a = np.array([ list(map(int, input().split())) for _ in range(n) ])

r = np.linalg.matrix_rank(a)
ans = (modpow(2, n+m-1) - modpow(2, n+m-r-1)) % mod

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
M=998244353
n,m=map(int, input().split())
a=np.array([list(map(int, input().split())) for _ in [0]*n])
r=int(np.linalg.matrix_rank(a))
print((pow(2,n+m-1,M)-pow(2,n+m-r-1,M))%M)

Submission status: Wrong Answer

Solution code:
import numpy as np
mod=998244353
n,m=map(int,input().split())
a=[0]*n
for i in range(n):
    a[i] = list(map(int,input().split()))
rnk = np.linalg.matrix_rank(np.array(a,dtype='int32'))
x=n-rnk
y=m-rnk

def powe(n,e):
    ret=1
    b=n
    while e>0:
        if e%2==1:
            ret*=b
        b=b*b
        ret%=mod
        b%=mod
        e//=2
    return ret

table = [[0]*301 for x in range(301)]

def inv(q):
    return powe(q,mod-2)

for i in range(301):
    table[i][0]=1
for p in range(301):
    for q in range(1,p+1):
        table[p][q] = (table[p][q-1]*(p-q+1)*inv(q))%mod
def nck(p,q):
    return table[p][q]
ret=0
for s in range(1,rnk+1):
    odds=0
    for t in range(1,s+1):
        if t%2==1:
            odds+=nck(s,t)
            odds%=mod
    ret+=nck(rnk,s)*odds*powe(2,rnk-s)
    ret%=mod
print((ret*powe(2,x)*powe(2,y))%mod)

Submission status: Wrong Answer

Solution code:
import numpy as np
mod=998244353
n,m=map(int,input().split())
a=[0]*n
for i in range(n):
    a[i] = list(map(int,input().split()))
rnk = np.linalg.matrix_rank(np.array(a))
x=n-rnk
y=m-rnk

def powe(n,e):
    ret=1
    b=n
    while e>0:
        if e%2==1:
            ret*=b
        b=b*b
        ret%=mod
        b%=mod
        e//=2
    return ret

table = [[0]*301 for x in range(301)]

def inv(q):
    return powe(q,mod-2)

for i in range(301):
    table[i][0]=1
for p in range(301):
    for q in range(1,p+1):
        table[p][q] = (table[p][q-1]*(p-q+1)*inv(q))%mod
def nck(p,q):
    return table[p][q]
ret=0
for s in range(1,rnk+1):
    odds=0
    for t in range(1,s+1):
        if t%2==1:
            odds+=nck(s,t)
            odds%=mod
    ret+=nck(rnk,s)*odds*powe(2,rnk-s)
    ret%=mod
print((ret*powe(2,x)*powe(2,y))%mod)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m=map(int,input().split())
mod=998244353
A=np.empty((0,m))
for _ in range(n):
    A=np.append(A,np.array([list(map(int,input().split()))]),axis=0)
if n>m:
    A=A.T
rank=np.linalg.matrix_rank(A)
a=1
b=1
for _ in range(n+m-1):
    a*=2
    a%=mod
for _ in range(n+m-rank-1):
    b*=2
    b%=mod
ans=(a-b)%mod
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
mod=998244353
n,m=map(int,input().split())
a=[0]*n
for i in range(n):
    a[i] = list(map(int,input().split()))
rnk = np.linalg.matrix_rank(np.array(a))
x=n-rnk
y=m-rnk

def powe(n,e):
    ret=1
    b=n
    while e>0:
        if e%2==1:
            ret*=b
        b=b*b
        ret%=mod
        b%=mod
        e//=2
    return ret

table = [[0]*301 for x in range(301)]

def inv(q):
    return powe(q,mod-2)

for i in range(301):
    table[i][0]=1
for p in range(301):
    for q in range(1,p+1):
        table[p][q] = (table[p][q-1]*(p-q+1)*inv(q))%mod
def nck(p,q):
    return table[p][q]
ret=0
for s in range(1,rnk+1):
    odds=0
    for t in range(1,s+1):
        if t%2==1:
            odds+=nck(s,t)
            odds%=mod
    ret+=nck(rnk,s)*odds*powe(2,rnk-s)
    ret%=mod
print(ret)

Submission status: Wrong Answer

Solution code:
import numpy as np
mod=998244353
n,m=map(int,input().split())
a=[0]*n
for i in range(n):
    a[i] = list(map(int,input().split()))
rnk = np.linalg.matrix_rank(np.array(a))
x=n-rnk
y=m-rnk

def powe(n,e):
    ret=1
    b=n
    while e>0:
        if e%2==1:
            ret*=b
        b=b*b
        ret%=mod
        b%=mod
        e//=2
    return ret

table = [[0]*301 for x in range(301)]

def inv(q):
    return powe(q,mod-2)

for i in range(301):
    table[i][0]=1
for p in range(301):
    for q in range(1,p+1):
        table[p][q] = (table[p][q-1]*(p-q+1)*inv(q))%mod
def nck(p,q):
    return table[p][q]
ret=0
for s in range(1,rnk+1):
    odds=0
    for t in range(1,s+1):
        if t%2==1:
            odds+=nck(s,t)
            odds%=mod
    ret+=nck(rnk,s)*odds*powe(2,rnk-s)
    ret%=mod
print(ret)
print((ret*powe(2,x)*powe(2,y))%mod)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m=map(int,input().split())
mod=998244353
A=np.empty((0,m))
for _ in range(n):
    A=np.append(A,np.array([list(map(int,input().split()))]),axis=0)
rank=np.linalg.matrix_rank(A)
a=1
b=1
for _ in range(n+m-1):
    a*=2
    a%=mod
for _ in range(n+m-rank-1):
    b*=2
    b%=mod
ans=(a-b)%mod
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m=map(int,input().split())
mod=998244353
A=[]
for _ in range(n):
    A.append(list(map(int,input().split())))
rank=np.linalg.matrix_rank(A)
a=1
b=1
for _ in range(n+m-1):
    a*=2
    a%=mod
for _ in range(n+m-rank-1):
    b*=2
    b%=mod
ans=(a-b)%mod
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m=map(int,input().split())
mod=998244353
A=[]
for _ in range(n):
    A.append(list(map(int,input().split())))
rank=np.linalg.matrix_rank(A)
a=1
b=1
for _ in range(n+m-1):
    a*=2
    a%=mod
for _ in range(n+m-rank-1):
    b*=2
    b%=mod
print(a-b)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m=map(int,input().split())
mod=998244353
A=[]
for _ in range(n):
    A.append(list(map(int,input().split())))
rank=np.linalg.matrix_rank(A)
ans=2**(n+m-1)%mod-2**(n+m-rank-1)%mod
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m=map(int,input().split())
mod=998244353
A=[]
for _ in range(n):
    A.append(list(map(int,input().split())))
rank=np.linalg.matrix_rank(A)
ans=((2**(n+m)-2**(n+m-rank))//2)%mod
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m=map(int,input().split())
A=[]
for _ in range(n):
    A.append(list(map(int,input().split())))
rank=np.linalg.matrix_rank(A)
ans=(2**(n+m)-2**(n+m-rank))//2
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
mod=998244353
n,m=map(int,input().split())
a=[0]*n
for i in range(n):
    a[i] = list(map(int,input().split()))
rnk = np.linalg.matrix_rank(a)

def powe(n,e):
    ret=1
    b=n
    while e>0:
        if e%2==1:
            ret*=b
        b=b*b
        ret%=mod
        b%=mod
        e//=2
    return ret

print((mod+powe(2,n+m-1)-powe(2,n+m-rnk-1))%mod)

Submission status: Wrong Answer

Solution code:
#!venv/bin/python

import math

N,M = [int(x) for x in input().split()]
A = []
for i in range(N):
    A.append([int(x) for x in input().split()])

MOD = 998244353

A0 = []
A0_num = 0
for i in range(N):
    a = A[i]
    for n in a:
        if n == 1:
            A0.append(False)
            break
    else:
        A0.append(True)
        A0_num += 1

col_sum = [0 for i in range(M)]
# print(A)
for col in range(M):
    col_sum[col] += sum([x[col] for x in A])

# print(col_sum)

smallest_col_sum = sorted(col_sum)[0]
# print(smallest_col_sum)

def cmb_mod(n, k, mod=998244353):
    # nCk (mod m)
    def mod_permutation(n, k, mod):
        if n<=k:
            return 1
        else:
            return (n * mod_permutation(n-1,k,mod))%mod

    def mod_inv_permutation(k, mod):
        k, mod = int(k), int(mod)
        if k<=1:
            return 1
        else:
            return (pow(k,mod-2,mod) * mod_inv_permutation(k-1, mod))%mod

    return (mod_permutation(n,n-k,mod) * mod_inv_permutation(k, mod))%mod

dame_pair = 0
for evenval in range(2,smallest_col_sum + 1,2):
    dame_pair += cmb_mod(smallest_col_sum,evenval)
if dame_pair == 0:
    dame_pair = 1

ans = 1
for i in range(N):
    ans = ans * 2
    ans = ans % MOD
# print("ans")
# print(ans)

# print("a0 num")
# print(A0_num)
dame = dame_pair
for i in range(A0_num):
    dame = dame * 2
    dame = dame % MOD
#dame += 1   # 0
# print("dame")
# print(dame)

ans = (ans - dame) % MOD
for i in range(M-1):
    ans = ans * 2
    ans = ans % MOD

print(ans)

Submission status: Wrong Answer

Solution code:
#!venv/bin/python

import math

N,M = [int(x) for x in input().split()]
A = []
for i in range(N):
    A.append([int(x) for x in input().split()])

MOD = 998244353

A0 = []
A0_num = 0
for i in range(N):
    a = A[i]
    for n in a:
        if n == 1:
            A0.append(False)
            break
    else:
        A0.append(True)
        A0_num += 1

col_sum = [0 for i in range(M)]
# print(A)
for col in range(M):
    col_sum[col] += sum([x[col] for x in A])

# print(col_sum)

smallest_col_sum = sorted(col_sum)[0]
# print(smallest_col_sum)

def cmb_mod(n, k, mod=998244353):
    # nCk (mod m)
    def mod_permutation(n, k, mod):
        if n<=k:
            return 1
        else:
            return (n * mod_permutation(n-1,k,mod))%mod

    def mod_inv_permutation(k, mod):
        k, mod = int(k), int(mod)
        if k<=1:
            return 1
        else:
            return (pow(k,mod-2,mod) * mod_inv_permutation(k-1, mod))%mod

    return (mod_permutation(n,n-k,mod) * mod_inv_permutation(k, mod))%mod

dame_pair = 0
for evenval in range(2,smallest_col_sum + 1,2):
    dame_pair += cmb_mod(smallest_col_sum,evenval)

ans = 1
for i in range(N):
    ans = ans * 2
    ans = ans % MOD
# print("ans")
# print(ans)

# print("a0 num")
# print(A0_num)
dame = dame_pair + 1
for i in range(A0_num):
    dame = dame * 2
    dame = dame % MOD
#dame += 1   # 0
# print("dame")
# print(dame)

ans = (ans - dame) % MOD
for i in range(M-1):
    ans = ans * 2
    ans = ans % MOD

print(ans)

Submission status: Wrong Answer

Solution code:
# 800 points
import math


# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
n, m = map(int, input().split())


matrix = []

for k in range(n):

    str_row = input().split()
    row = []
    for j in range(m):

        row.append(int(str_row[j]) % 2)

    matrix.append(row)
res_sum = 0

for mmin in range(m):
    for mmax in range(mmin, m):
        for nmin in range(n):
            for nmax in range(nmin, n):

                print(mmin,mmax,nmin,nmax)
                counter = 0
                for mi in range(mmin, mmax + 1):
                    for ni in range(nmin, nmax + 1):
                        counter += matrix[ni][mi]
                        print(mi,ni)

                print("couner",counter)

                if counter % 2 == 1:
                    res_sum = (res_sum + 1) % 998244353


print(res_sum)

Submission status: Wrong Answer

Solution code:
import numpy as np
mod=998244353
n,m=map(int,input().split())
a=[0]*n
for i in range(n):
    a[i] = list(map(int,input().split()))
rnk = np.linalg.matrix_rank(a)
x=n-rnk
y=m-rnk

def powe(n,e):
    ret=1
    b=n
    while e>0:
        if e%2==1:
            ret*=b
        b=b*b
        ret%=mod
        b%=mod
        e//=2
    return ret

table = [[0]*301 for x in range(301)]

def inv(q):
    return powe(q,mod-2)

for i in range(301):
    table[i][0]=1
for p in range(301):
    for q in range(1,p+1):
        table[p][q] = (table[p][q-1]*(p-q+1)*inv(q))%mod
def nck(p,q):
    return table[p][q]

ret=0
for s in range(1,rnk+1):
    odds=0
    for t in range(1,s+1):
        if t%2==1:
            odds+=nck(s,t)
            odds%=mod
    ret+=nck(rnk,s)*odds*powe(2,rnk-s)
    ret%=mod

print((ret*powe(2,x)*powe(2,y))%mod)

Submission status: Wrong Answer

Solution code:
import numpy as np
NM = [int(x) for x in input().split()]
N = NM[0]
M = NM[1]
a = [[int(x) for x in input().split()] for l in range(N)]
#print(a)
A =np.array(a)
count = 0

for i in range (0, M):
    for j in range(i, M):
        for k in range (0, N):
            for l in range(k, N):
                if A[i:j+1,k:l+1].sum() % 2 == 1:
                    #print(a)
                    #print(i,j,k,l,A[i:j+1,k:l+1])
                    count += 1
print(count % 998244353)

Submission status: Wrong Answer

Solution code:
import numpy as np
n, m = map(int, input().split())
f = n * m > 998244353
lis = []
for i in range(n):
  lis.append(list(map(int, input().split())))
arr = np.array(lis)
cache_dict = {}

def search(base, x1, x2, y1, y2):
  use_arr = arr[x1:x2+1, y1:y2+1]
  return (base + use_arr.sum()) % 2

def rec_search(base, x1, x2, y1, y2):
  cache_dict[(x1, x2, y1, y2)] = base
  if x1-1 >= 0:
    arg1 = (x1-1, x2, y1, y2)
    if not arg1 in cache_dict:
      next_base = search(base, x1-1, x1-1, y1, y2)
      cache_dict[arg1] = next_base
      rec_search(next_base, x1-1, x2, y1, y2)
  if x2+1 <= m-1:
    arg2 = (x1, x2+1, y1, y2)  
    if not arg2 in cache_dict:
      next_base = search(base, x2+1, x2+1, y1, y2)
      cache_dict[arg2] = next_base
      rec_search(next_base, x1, x2+1, y1, y2)
  if y1 - 1 >= 0:
    arg3 = (x1, x2, y1-1, y2)  
    if not arg3 in cache_dict:
      next_base = search(base, x1, x2, y1-1, y1-1)
      cache_dict[arg3] = next_base
      rec_search(next_base, x1, x2, y1-1, y2)
  if y2 + 1 <= n-1:
    arg4 = (x1, x2, y1, y2+1)  
    if not arg4 in cache_dict:
      next_base = search(base, x1, x2, y2+1, y2+1)
      cache_dict[arg4] = next_base
      rec_search(next_base, x1, x2, y1, y2+1)

point_1 = np.where(arr==1)
for ind in zip(point_1[0], point_1[1]):
  cache_dict[(ind[1], ind[1], ind[0], ind[0])] = 1
  rec_search(1, ind[1], ind[1], ind[0], ind[0])
print(sum(cache_dict.values()) % 998244353)