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 i in range(n)]
MOD = 998244353


ru = [[0] * (m + 1) for i in range(n)]
for i in range(n):
    for j in range(m):
        ru[i][j + 1] = ru[i][j] + a[i][j]

ans = 0
for l in range(m):
    for r in range(l + 1, m + 1):
        cnt = []
        for i in range(n):
            cnt.append((ru[i][r] - ru[i][l]) % 2)
        
        dp = [[0] * (n + 1) for i in range(2)]
        for i, val in enumerate(cnt):
            dp[val][i + 1] = 1
            dp[0 ^ val][i + 1] += dp[0][i]
            dp[0 ^ val][i + 1] %= MOD
            dp[1 ^ val][i + 1] += dp[1][i]
            dp[1 ^ val][i + 1] %= MOD
        ans += sum(dp[1])
        ans %= MOD
print(ans)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split());mod=998244353;B=set([0])
for i in range(N):
    A=input().split();s=sum(int(A[j])*2**j for j in range(M))
    for b in B:s=min(s,s^b)
    B.add(s)
print((pow(2,N+M-1,mod)*(1-pow(2,mod-len(B),mod)))%mod)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = [int(input().replace(" ",""),2) for i in range(n)]
mod = 998244353
cnt = 0
for j in range(m)[::-1]:
  for i in range(cnt,n):
    if a[i] & 1<<j:
      for k in range(n):
        if (i != k) and (a[k] & 1<<j):
          a[k] ^= a[i]
      a[i],a[cnt] = a[cnt],a[i]
      cnt += 1
"""
ans = pow(2,n+m-2*cnt,mod)*pow(2,cnt-1,mod)*(pow(2,cnt,mod)-1)%mod
print(ans)
"""

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline

    mod = 998244353
    N, M = map(int, input().split())
    grid = []
    for _ in range(N):
        line = list(map(bool, map(int, input().split())))
        grid.append(line)

    cs = [[False] * (M+1) for _ in range(N+1)]
    for i in range(N):
        for j in range(M):
            cs[i+1][j+1] = cs[i+1][j] ^ cs[i][j+1] ^ cs[i][j] ^ grid[i][j]

    ans = 0
    for i in range(N+1):
        for j in range(i+1, N+1):
            one = 0
            for k in range(M+1):
                if cs[i][k] ^ cs[j][k]:
                    one += 1
            ans = (ans + (one * (M+1 - one))%mod)%mod
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return list(sys.stdin.readline())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007

#A
"""
n,k = LI()
if 2*(k-1) < n:
    print("YES")
else:
    print("NO")
"""

#B
"""
c = LIR(3)
v = [[] for i in range(4)]
for i in range(3):
    c[i][0] -= 1
    c[i][1] -= 1
    v[c[i][0]].append(c[i][1])
    v[c[i][1]].append(c[i][0])

for i in range(4):
    li = [True for i in range(4)]
    li[i] = False
    q = [i]
    c = 0
    while q:
        x = q.pop(-1)
        k = 0
        for j in v[x]:
            if li[j]:
                li[j] = False
                q.append(j)
                if k == 0:
                    c += 1
                    k += 1
    if c == 3:
        print("YES")
        quit()
print("NO")
"""

#C
"""
k,a,b = LI()
if k <= a:
    print(k+1)
else:
    if b-a < 3:
        print(k+1)
    else:
        ans = a+((k-a+1)//2)*(b-a)+(k-a+1)%2
        print(ans)
"""

#D

#E
n,m = LI()
a = LIR(n)
a.sort()
a = a[::-1]
for i in range(n):
    for j in range(i+1,n):
        s = 0
        while a[i][s] == 0 and s < m-1:s+=1
        if s < m and a[i][s] != 0:
            if a[j][s] > 0:
                for k in range(s,m):
                    a[j][k] -= 1
                    a[j][k] = abs(a[j][k])
r = 0
for i in range(n):
    if sum(a[i]) > 0:r += 1
print((pow(2,n+m-1)-pow(2,n-r+m-1))%998244353)
#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return list(sys.stdin.readline())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007

#A
"""
n,k = LI()
if 2*(k-1) < n:
    print("YES")
else:
    print("NO")
"""

#B
"""
c = LIR(3)
v = [[] for i in range(4)]
for i in range(3):
    c[i][0] -= 1
    c[i][1] -= 1
    v[c[i][0]].append(c[i][1])
    v[c[i][1]].append(c[i][0])

for i in range(4):
    li = [True for i in range(4)]
    li[i] = False
    q = [i]
    c = 0
    while q:
        x = q.pop(-1)
        k = 0
        for j in v[x]:
            if li[j]:
                li[j] = False
                q.append(j)
                if k == 0:
                    c += 1
                    k += 1
    if c == 3:
        print("YES")
        quit()
print("NO")
"""

#C
"""
k,a,b = LI()
if k <= a:
    print(k+1)
else:
    if b-a < 3:
        print(k+1)
    else:
        ans = a+((k-a+1)//2)*(b-a)+(k-a+1)%2
        print(ans)
"""

#D

#E
import numpy as np
n,m = LI()
a = LIR(n)
a = np.array(a)
"""
for i in range(n):
    for j in range(i+1,n):
        s = 0
        while a[i][s] == 0 and s < m-1:s+=1
        if s < m and a[i][s] == 0:
            if a[j][s] > 0:
                d = a[j][s]/a[i][s]
                for k in range(s,m):
                    a[j][k] -= d*a[i][k]
r = 0
for i in range(n):
    if sum(a[i]) != 0:
        r += 1
"""
r = np.linalg.matrix_rank(a)
print((((pow(2,n)-pow(2,n-r))%998244353)*pow(2,m-1))%998244353)
#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return list(sys.stdin.readline())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007

#A
"""
n,k = LI()
if 2*(k-1) < n:
    print("YES")
else:
    print("NO")
"""

#B
"""
c = LIR(3)
v = [[] for i in range(4)]
for i in range(3):
    c[i][0] -= 1
    c[i][1] -= 1
    v[c[i][0]].append(c[i][1])
    v[c[i][1]].append(c[i][0])

for i in range(4):
    li = [True for i in range(4)]
    li[i] = False
    q = [i]
    c = 0
    while q:
        x = q.pop(-1)
        k = 0
        for j in v[x]:
            if li[j]:
                li[j] = False
                q.append(j)
                if k == 0:
                    c += 1
                    k += 1
    if c == 3:
        print("YES")
        quit()
print("NO")
"""

#C
"""
k,a,b = LI()
if k <= a:
    print(k+1)
else:
    if b-a < 3:
        print(k+1)
    else:
        ans = a+((k-a+1)//2)*(b-a)+(k-a+1)%2
        print(ans)
"""

#D

#E
import numpy as np
n,m = LI()
a = LIR(n)
a = np.array(a)
"""
for i in range(n):
    for j in range(i+1,n):
        s = 0
        while a[i][s] == 0 and s < m-1:s+=1
        if s < m and a[i][s] == 0:
            if a[j][s] > 0:
                d = a[j][s]/a[i][s]
                for k in range(s,m):
                    a[j][k] -= d*a[i][k]
r = 0
for i in range(n):
    if sum(a[i]) != 0:
        r += 1
"""
r = np.linalg.matrix_rank(a)
print((pow(2,n+m-1)-pow(2,n-r+m-1))%998244353)
#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return list(sys.stdin.readline())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007

#A
"""
n,k = LI()
if 2*(k-1) < n:
    print("YES")
else:
    print("NO")
"""

#B
"""
c = LIR(3)
v = [[] for i in range(4)]
for i in range(3):
    c[i][0] -= 1
    c[i][1] -= 1
    v[c[i][0]].append(c[i][1])
    v[c[i][1]].append(c[i][0])

for i in range(4):
    li = [True for i in range(4)]
    li[i] = False
    q = [i]
    c = 0
    while q:
        x = q.pop(-1)
        k = 0
        for j in v[x]:
            if li[j]:
                li[j] = False
                q.append(j)
                if k == 0:
                    c += 1
                    k += 1
    if c == 3:
        print("YES")
        quit()
print("NO")
"""

#C
"""
k,a,b = LI()
if k <= a:
    print(k+1)
else:
    if b-a < 3:
        print(k+1)
    else:
        ans = a+((k-a+1)//2)*(b-a)+(k-a+1)%2
        print(ans)
"""

#D

#E
n,m = LI()
a = LIR(n)
a.sort()
a = a[::-1]
for i in range(n):
    for j in range(i+1,n):
        s = 0
        while a[i][s] == 0 and s < m-1:s+=1
        if s < m and a[i][s] != 0:
            if a[j][s] > 0:
                d = a[j][s]/a[i][s]
                for k in range(s,m):
                    a[j][k] -= d*a[i][k]
r = 0
for i in range(n):
    if sum(a[i]) > 0:r += 1
print((pow(2,n+m-1)-pow(2,n-r+m-1))%998244353)
#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return list(sys.stdin.readline())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007

#A
"""
n,k = LI()
if 2*(k-1) < n:
    print("YES")
else:
    print("NO")
"""

#B
"""
c = LIR(3)
v = [[] for i in range(4)]
for i in range(3):
    c[i][0] -= 1
    c[i][1] -= 1
    v[c[i][0]].append(c[i][1])
    v[c[i][1]].append(c[i][0])

for i in range(4):
    li = [True for i in range(4)]
    li[i] = False
    q = [i]
    c = 0
    while q:
        x = q.pop(-1)
        k = 0
        for j in v[x]:
            if li[j]:
                li[j] = False
                q.append(j)
                if k == 0:
                    c += 1
                    k += 1
    if c == 3:
        print("YES")
        quit()
print("NO")
"""

#C
"""
k,a,b = LI()
if k <= a:
    print(k+1)
else:
    if b-a < 3:
        print(k+1)
    else:
        ans = a+((k-a+1)//2)*(b-a)+(k-a+1)%2
        print(ans)
"""

#D

#E
import numpy as np
n,m = LI()
a = LIR(n)
a = np.array(a)
"""
for i in range(n):
    for j in range(i+1,n):
        s = 0
        while a[i][s] == 0 and s < m-1:s+=1
        if s < m and a[i][s] == 0:
            if a[j][s] > 0:
                d = a[j][s]/a[i][s]
                for k in range(s,m):
                    a[j][k] -= d*a[i][k]
r = 0
for i in range(n):
    if sum(a[i]) != 0:
        r += 1
"""
r = np.linalg.matrix_rank(a)
print(pow(2,n+m-1)-pow(2,n-r+m-1))
#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return list(sys.stdin.readline())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007

#A
"""
n,k = LI()
if 2*(k-1) < n:
    print("YES")
else:
    print("NO")
"""

#B
"""
c = LIR(3)
v = [[] for i in range(4)]
for i in range(3):
    c[i][0] -= 1
    c[i][1] -= 1
    v[c[i][0]].append(c[i][1])
    v[c[i][1]].append(c[i][0])

for i in range(4):
    li = [True for i in range(4)]
    li[i] = False
    q = [i]
    c = 0
    while q:
        x = q.pop(-1)
        k = 0
        for j in v[x]:
            if li[j]:
                li[j] = False
                q.append(j)
                if k == 0:
                    c += 1
                    k += 1
    if c == 3:
        print("YES")
        quit()
print("NO")
"""

#C
"""
k,a,b = LI()
if k <= a:
    print(k+1)
else:
    if b-a < 3:
        print(k+1)
    else:
        ans = a+((k-a+1)//2)*(b-a)+(k-a+1)%2
        print(ans)
"""

#D

#E
n,m = LI()
a = LIR(n)
a.sort()
a = a[::-1]
for i in range(n):
    for j in range(i+1,n):
        s = 0
        while a[i][s] == 0 and s < m-1:s+=1
        if s < m and a[i][s] == 0:
            if a[j][s] > 0:
                d = a[j][s]/a[i][s]
                for k in range(s,m):
                    a[j][k] -= d*a[i][k]
r = 0
for i in range(n):
    if sum(a[i]) != 0:
        r += 1
print(pow(2,n+m-1)-pow(2,n-r+m-1))
#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Wrong Answer

Solution code:
import numpy as np
import random

mod=998244353


n,m=map(int,input().split())
A=[list(map(int,input().split())) for i in range(n)]

#n,m=300,300
#A=[[int(random.randint(0,1)) for j in range(m)] for i in range(n)]


#A=np.array(A)

#print("A")
i=0
j=0
r=0 #rank
while i<n and j<m :
    #print(i)
    t=0
    if A[i][j]==0 :
        k=i
        while k<n and A[k][j]==0 :
            k+=1
        if k<n :
            A[i],A[k]=A[k],A[i]

            #print(A)
        else :
            t=1
            j+=1
    if t==0 :
        r+=1
        for p in range(i+1,n):
            if A[p][j]>0 :
                for kk in range(j,m):
                    A[p][kk]=(A[p][kk]-A[i][kk])%2
        i+=1
        j+=1



#r=0
#j=0
#for i in range(m):
#    if j<n :
#        if A[j][i]!=0 :
#            r+=1
#            j+=1

for i in range(n):
    for j in range(m):
        A[i][j]=int(A[i][j])
#print(A)
print(r) #rank

a=1
b=1

for i in range(n+m-1):
    a=(a*2)%mod
for i in range(n+m-1-r):
    b=(b*2)%mod

print((a-b)%mod)

Submission status: Wrong Answer

Solution code:
import numpy as np
import random

mod=998244353


#n,m=map(int,input().split())
#A=[list(map(int,input().split())) for i in range(n)]

n,m=300,300
A=[[int(random.randint(0,1)) for j in range(m)] for i in range(n)]


#A=np.array(A)

#print("A")
i=0
j=0
r=0 #rank
while i<n and j<m :
    #print(i)
    t=0
    if A[i][j]==0 :
        k=i
        while k<n and A[k][j]==0 :
            k+=1
        if k<n :
            A[i],A[k]=A[k],A[i]

            #print(A)
        else :
            t=1
            j+=1
    if t==0 :
        r+=1
        for p in range(i+1,n):
            if A[p][j]>0 :
                for kk in range(j,m):
                    A[p][kk]=(A[p][kk]-A[i][kk])%2
        i+=1
        j+=1



#r=0
#j=0
#for i in range(m):
#    if j<n :
#        if A[j][i]!=0 :
#            r+=1
#            j+=1

for i in range(n):
    for j in range(m):
        A[i][j]=int(A[i][j])
#print(A)
print(r) #rank

a=1
b=1

for i in range(n+m-1):
    a=(a*2)%mod
for i in range(n+m-1-r):
    b=(b*2)%mod

print((a-b)%mod)

Submission status: Wrong Answer

Solution code:
import numpy as np
import random

mod=998244353


n,m=map(int,input().split())
A=[list(map(float,input().split())) for i in range(n)]

#n,m=300,250

#A=[[float(random.randint(0,1)) for j in range(m)] for i in range(n)]

if n<m :
    n,m=m,n
    A=np.array(A)
    A=A.T
    A=list(A)



# if A[0][0]!=0

#print(A)
for i in range(min(n,m)):
    #print(A)
    A=list(A)
    A[i:].sort(reverse=1,key=lambda x:x[i])
    if A[i][i]==0 :
        A[i:].sort(key=lambda x:x[i])
    A=np.array(A)
    if A[i][i]!=0 :
        w=A[i][i]
        for k in range(m):
            
            A[i][k]/=w
        for j in range(i+1,n):
            A[j]-=A[i]*A[j][i]

#print(A)

r=0
j=0
for i in range(m):
    if j<n :
        if A[j][i]!=0 :
            r+=1
            j+=1

for i in range(n):
    for j in range(m):
        A[i][j]=int(A[i][j])
#print(A)
#print(r) #rank

a=1
b=1

for i in range(n+m-1):
    a=(a*2)%mod
for i in range(n+m-1-r):
    b=(b*2)%mod

print((a-b)%mod)

Submission status: Wrong Answer

Solution code:
import numpy as np
import random

mod=998244353


#n,m=map(int,input().split())
#A=[list(map(float,input().split())) for i in range(n)]

n,m=300,250

A=[[float(random.randint(0,1)) for j in range(m)] for i in range(n)]

if n<m :
    n,m=m,n
    A=np.array(A)
    A=A.T
    A=list(A)



# if A[0][0]!=0

#print(A)
for i in range(min(n,m)):
    #print(A)
    A=list(A)
    A[i:].sort(reverse=1,key=lambda x:x[i])
    if A[i][i]==0 :
        A[i:].sort(key=lambda x:x[i])
    A=np.array(A)
    if A[i][i]!=0 :
        w=A[i][i]
        for k in range(m):
            
            A[i][k]/=w
        for j in range(i+1,n):
            A[j]-=A[i]*A[j][i]

#print(A)

r=0
j=0
for i in range(m):
    if j<n :
        if A[j][i]!=0 :
            r+=1
            j+=1

for i in range(n):
    for j in range(m):
        A[i][j]=int(A[i][j])
#print(A)
#print(r) #rank

a=1
b=1

for i in range(n+m-1):
    a=(a*2)%mod
for i in range(n+m-1-r):
    b=(b*2)%mod

print((a-b)%mod)

Submission status: Wrong Answer

Solution code:
import numpy as np
import random

mod=998244353


#n,m=map(int,input().split())
#A=[list(map(float,input().split())) for i in range(n)]

n,m=300,250

A=[[float(random.randint(0,1)) for j in range(m)] for i in range(n)]

if n<m :
    n,m=m,n
    A=np.array(A)
    A=A.T
    A=list(A)



# if A[0][0]!=0

#print(A)
for i in range(min(n,m)):
    #print(A)
    A=list(A)
    A[i:].sort(reverse=1,key=lambda x:x[i])
    if A[i][i]==0 :
        A[i:].sort(key=lambda x:x[i])
    A=np.array(A)
    if A[i][i]!=0 :
        w=A[i][i]
        for k in range(m):
            
            A[i][k]/=w
        for j in range(i+1,n):
            A[j]-=A[i]*A[j][i]

#print(A)

r=0
j=0
for i in range(m):
    if j<n :
        if A[j][i]!=0 :
            r+=1
            j+=1

for i in range(n):
    for j in range(m):
        A[i][j]=int(A[i][j])
#print(A)
print(r) #rank

a=1
b=1

for i in range(n+m-1):
    a=(a*2)%mod
for i in range(n+m-1-r):
    b=(b*2)%mod

print((a-b)%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 range(n)])

#F2で考えている
def rank(a):
    n, m = len(a), len(a[0])
    rank = 0
    i, j = 0, 0
    while i < n and j < m:
        if a[i][j]:
            rank += 1
        else:
            for ii in range(i+1, n):
                if a[ii][j]:
                    a[i], a[ii] = a[ii], a[i]
                    rank += 1
                    break

            #breakで終わらなかった場合
            else:
                j += 1
                continue
        for ii in range(i+1, n):
            if a[ii][j]:
                for jj in range(j, m):
                    a[ii][jj] = (a[ii][jj] + a[i][jj])%2
        i += 1
        j += 1

    return rank

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

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 range(n)])
if n > m:
    a = a.T
    n, m = m, n
r = int(np.linalg.matrix_rank(a))
ans = (pow(2, n+m-1, mod)-pow(2, n+m-r-1, mod))%mod
print(ans)

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 range(n)])
r = int(np.linalg.matrix_rank(a))
print((pow(2, n+m-1, mod)-pow(2, n+m-r-1, mod))%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 range(n)])
r = int(np.linalg.matrix_rank(a))
print(pow(2, n+m-1, mod)-pow(2, n+m-r-1, mod))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
IN=lambda:list(map(int,input().split()))
p=998244353
n,m=IN()
a=np.array([IN() for i in range(n)])
r=np.linalg.matrix_rank(a)
f=n+m-1
d=f-r
print((p+pow(2,f,p)-pow(2,d,p))%p)

Submission status: Wrong Answer

Solution code:
import numpy as np
IN=lambda:list(map(int,input().split()))
p=998244353
n,m=IN()
a=np.array([IN() for i in range(n)])
r=np.linalg.matrix_rank(a)
f=n+m-1
d=f-r
print((pow(2,f,p)-pow(2,d,p))%p)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = [ [int(j) for j in input().split()] for _ in range(N)]

import numpy as np

rank = np.linalg.matrix_rank(np.array(A)).item()

ans = 1
sub = 1

MOD = 998244353
# ans = 2**(N+M-r-r) * ( 2**r - 1 ) * ( 2 ** (r-1) )
#     = 2**(N+M-r) * 2**(r-1) - 2**(N+M-r-1)
#     = 2**(N+M-1)    - 2**(N+M-r-1)

ans = pow(2, N+M-1 , MOD)
sub = pow(2, N+M-rank-1, MOD)

print( (ans - sub)%MOD)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
IN=lambda:list(map(int,input().split()))
PJ=lambda x:pow(2,x,998244353)
n,m=IN()
a=np.array([IN() for i in range(n)])
r=np.linalg.matrix_rank(a)
print(PJ(n*m-1)-PJ(n*m-1-r))

Submission status: Wrong Answer

Solution code:
import numpy as np
IN=lambda:list(map(int,input().split()))
PJ=lambda x:pow(2,x,998244353)
n,m=IN()
a=np.array([IN() for i in range(n)])
r=np.linalg.matrix_rank(a)
print(PJ(n+m-1)-PJ(n+m-1-r))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M=map(int, raw_input().split())
A=[ map(int, raw_input().split()) for i in range(N) ]

for k in range( min(N,M) ): #k: pivot
	if A[k][k]==0:
		for i in range(N):
			if A[i][k]==1:
				#Gyou koukan
				A[k],A[i] = A[i],A[k]
				break

	for i in range(N):
		if i!=k and A[i][k]==1:
			for j in range(M):
				A[i][j]+=A[i-1][j]
				A[i][j]%=2

r=0 #Rank

for x in A:
	if max(x)!=0: r+=1


p=998244353

print ( pow(2,N+M-1,p)-pow(2,N+M-r-1,p) )%p

Submission status: Wrong Answer

Solution code:
import numpy as np
 
n,m = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
 
a_np = np.array(a)
rank = np.linalg.matrix_rank(a_np)
 
teisu = 998244353
ans =(pow(2,n+m-1,teisu)-pow(2,n+m-1-rank,teisu))
print(ans%teisu)

Submission status: Wrong Answer

Solution code:
import numpy as np
 
n,m = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
 
a_np = np.array(a)
rank = np.linalg.matrix_rank(a_np)
 
teisu = 998244353
ans = (pow(2,m-1,teisu)*(pow(2,n,teisu)-pow(2,n-rank,teisu)))
print(ans%teisu)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

a_np = np.array(a)
rank = np.linalg.matrix_rank(a_np)

teisu = 998244353
print(pow(2,m-1,teisu)*(pow(2,n,teisu)-pow(2,n-rank,teisu)))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

a_np = np.array(a)
rank = np.linalg.matrix_rank(a_np)

print((2**(m-1))*(2**n - 2**(n-rank)))

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools
from scipy import signal
 
N, M = [int(s) for s in input().split()]
A = np.zeros([N, M])
for n in range(N):
	A[n] = [int(m) for m in input().split()]
 
N_fft, M_fft = 2*N, 2*M
Fa = np.fft.rfft2(A, [N_fft,M_fft])
 
oddnum = 0
for n, m in itertools.product(range(N), range(M)):
	W = np.fft.rfft2(np.ones([n+1,m+1]), [N_fft,M_fft]);
	Aw = np.fft.irfft2(Fa*W).astype(int)
	oddnum += np.sum(Aw[n:N, m:M] % 2 == 1)
 
print(oddnum % 998244353)

Submission status: Wrong Answer

Solution code:
import itertools
def inpl(): return list(map(int, input().split()))
N, M = inpl()
G = [list(itertools.accumulate(inpl())) for _ in [0]*N]
G = list(map(list, zip(*G)))
G = [list(itertools.accumulate(g)) for g in G]
for j in range(M):
    G[j] = [v % 2 for v in G[j]]
Grow = [list(itertools.accumulate(g)) for g in G]
G = list(map(list, zip(*G)))
Grow = list(map(list, zip(*Grow)))
Gcol = [list(itertools.accumulate(g)) for g in G]

mod = 998244353
ans = 0
for i in range(N):
    for j in range(M):
        if G[i][j] % 2:
            ans += (Grow[i][j]-1)*(Gcol[i][j]-1) + (i+2-Grow[i][j])*(j+2-Gcol[i][j])   
        else:
            ans += Grow[i][j]*(j+1-Gcol[i][j]) + (i+1-Grow[i][j])*Gcol[i][j]
        ans %= mod
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools
from scipy import signal
 
N, M = [int(s) for s in input().split()]
A = np.zeros([N, M])
for n in range(N):
	A[n] = [int(m) for m in input().split()]

N_fft, M_fft = 2*N, 2*M
Fa = np.fft.rfft2(A, [N_fft,M_fft])

oddnum = 0
for n, m in itertools.product(range(N), range(M)):
	W = np.fft.rfft2(np.ones([n+1,m+1]), [N_fft,M_fft]);
	Aw = np.fft.irfft2(Fa*W).astype(int)
	print(Aw[n:N, m:M])
	oddnum += np.sum(Aw[n:N, m:M] % 2 == 1)
 
print(oddnum % 998244353)

Submission status: Wrong Answer

Solution code:
import numpy as np
 
N,M=map(int, raw_input().split())
A=np.array( [ map(int, raw_input().split()) for i in range(N) ] )
 
R=np.linalg.matrix_rank(A)
p=998244353

print ( pow(2,N+M-1,p)-pow(2,N+M-R-1,p) )%p

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools
from scipy import signal

N, M = [int(s) for s in input().split()]
A = np.zeros([N, M])
for n in range(N):
	A[n] = [int(m) for m in input().split()]

oddnum = 0
for n, m in itertools.product(range(N), range(M)):
	w = np.ones([n+1,m+1]);
	Aw = signal.convolve2d(A, w, 'valid').astype(int)
	oddnum += np.sum(Aw % 2 == 1)

print(oddnum % 998244353)

Submission status: Wrong Answer

Solution code:
import numpy as np
 
N,M=map(int, raw_input().split())
A=np.array( [ map(int, raw_input().split()) for i in range(N) ] )
 
R=np.linalg.matrix_rank(A)

print pow(2,N+M-1,998244353)-pow(2,N+M-R-1,998244353)

Submission status: Wrong Answer

Solution code:
import numpy as np
 
N,M=map(int, raw_input().split())
A=np.array( [ map(int, raw_input().split()) for i 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, raw_input().split())
A=np.array( [ map(int, raw_input().split()) for i 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

n,m = map(int, input().split())
A = np.array([ list(map(int, input().split())) for _ in range(n) ])
r = int(np.linalg.matrix_rank(A))
print((pow(2, n+m-1, 998244353) - pow(2, n+m-r-1, 998244353)) % 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+m-1) - 2**(n+m-r-1)) % 998244353)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
matrix=[list(map(int,input().split())) for i in range(n)]
def change(i,j,matrix):
    line=(matrix[i],matrix[j])
    matrix[i]=line[1]
    matrix[j]=line[0]
    return matrix

def kbai(i,k,matrix):
    for j in range(len(matrix[0])):
        matrix[i][j]*=k
    return matrix

def plus(i,j,k,matrix):
    for _  in range(len(matrix[0])):
        matrix[i][_]+=matrix[j][_]*k
    return matrix


def rank(n,m,matrix):
    now=0
    for j in range(m):
        exist=set()
        jiku=-1
        for i in range(n):
            if matrix[i][j]!=0:
                if jiku==-1 and i>=now:jiku=i
                else:exist|={i,}
        if jiku==-1:continue
        for x in range(len(exist)):
            y=exist.pop()
            matrix=plus(y,jiku,-1,matrix)
        matrix=change(jiku,now,matrix)
        now+=1
    return now


r=rank(n,m,matrix)
x,y=0,0
num=1
for i in range(1,n+m):
    num=num*2%998244353
    if i==n+m-r-1:y=num
    if i==n+m-1:x=num
print((x-y)%998244353)
#https://img.atcoder.jp/yahoo-procon2019-qual/editorial.pdf

Submission status: Wrong Answer

Solution code:
def intmod2(n):
    return int(n) % 2

def rankmod2(A):
    global N, M
    ret = 0
    i = 0
    j = 0
    while i < N and j < M:
        ii = i
        if A[i][j]:
            ret += 1
        else:
            for ii in range(i+1, N):
                if A[ii][j]:
                    A[i], A[ii] = A[ii], A[i]
                    ret += 1
                    break
            else:
                j += 1
                continue
                
        for ii in range(i+1, N):
            if A[ii][j]:
                for jj in range(j, M):
                    A[ii][jj] = (A[ii][jj] + A[i][jj]) % 2
        i += 1
        j += 1
        
    return ret
                        
P = 998244353
N, M = map(int, input().split())
A = [list(map(intmod2, input().split())) for _ in range(N)]

r = rankmod2(A)
print(pow(2, N+M-1, P)-pow(2, N+M-r-1, P))