Problem:


Score : 900 points

Problem Statement

We have a grid with (2^N - 1) rows and (2^M-1) columns.
You are asked to write 0 or 1 in each of these squares.
Let a_{i,j} be the number written in the square at the i-th row from the top and the j-th column from the left.

For a quadruple of integers (i_1, i_2, j_1, j_2) such that 1\leq i_1 \leq i_2\leq 2^N-1, 1\leq j_1 \leq j_2\leq 2^M-1, let
S(i_1, i_2, j_1, j_2) = \displaystyle \sum_{r=i_1}^{i_2}\sum_{c=j_1}^{j_2}a_{r,c}.
Then, let the oddness of the grid be the number of quadruples (i_1, i_2, j_1, j_2) such that S(i_1, i_2, j_1, j_2) is odd.

Find a way to fill in the grid that maximizes its oddness.

Constraints

N and M are integers between 1 and 10 (inclusive).

Input

Input is given from Standard Input in the following format:

N M

Output

Print numbers to write in the grid so that its oddness is maximized, in the following format:

a_{1,1}a_{1,2}\cdots a_{1,2^M-1}
a_{2,1}a_{2,2}\cdots a_{2,2^M-1}
\vdots
a_{2^N-1,1}a_{2^N-1,2}\cdots a_{2^N-1,2^M-1}

If there are multiple solutions, you can print any of them.

Sample Input 1

1 2

Sample Output 1

111

For this grid, S(1, 1, 1, 1), S(1, 1, 2, 2), S(1, 1, 3, 3), and S(1, 1, 1, 3) are odd, so it has the oddness of 4.

We cannot make the oddness 5 or higher, so this is one of the ways that maximize the oddness.



Sample input:
1 2


Sample output:
111

Submission status: Wrong Answer

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M=MI()
    N=2**N-1
    M=2**M-1
    ans = [[1^(j&1)^(i&1) for i in range(M)] for j in range(N)]
    for a in ans:
        print(*a,sep="")
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#At coder 2020/3/8 E
import math
N,M=list(map(int,input().split())) 
a = [1] * (2**N-1)
b = [1] * (2**M-1)

for ii in range(2**N-1):
    if ii%2!=0:
        for jj in range(2**M-1):
            b[jj]=jj%2
    else:
        for jj in range(2**M-1):
            b[jj]=(jj+1)%2
    print(*b)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
ans=[["1"]*(2**m-1) for _ in range(2**n-1)]
for i in range(0,2**n-2,2):
    for j in range(0,2**m-2,2):
        ans[i+1][j+1]="0"
for i in range(2**n-1):
    print("".join(ans[i]))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
ans = [[1 for j in range(2**m-1)] for i in range(2**n-1)]
for i in range(2**n-1):
  for j in range(2**m-1):
    if i%2 == j%2 == 1:
      ans[i][j] = 0
for arr in ans:
  print(*arr,sep="")

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
for i in range(2**n):
    print('1'*(2**m))

Submission status: Wrong Answer

Solution code:
#At coder 2020/3/8 E
import math
N,M=list(map(int,input().split())) 
a = [1] * (2**N-1)
b = [1] * (2**M-1)

for ii in range(2**N-1):
    print(*b)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
flag = True
for i in range(pow(2,n)-1):
    for j in range(pow(2,m)-1):
        if flag:
            print(1, end='')
        else:
            print(0, end='')
        flag = not flag
    print()

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())

L1 = []
L2 = []
for i in range(2**M-1):
    L1.append(str((i+1)%2))
    L2.append(str(i%2))

for i in range(2**N-1):
    if N == 1 or M == 1:
        print("1"*(2**M-1))
    elif i%2 == 0:
        print("".join(L1))
    else:
        print("".join(L2))

Submission status: Wrong Answer

Solution code:
def examA():
    S = SI()
    if len(S)%2==1:
        print("No")
        return
    for i in range(len(S)//2):
        if S[i*2:i*2+2]!="hi":
            print("No")
            return
    print("Yes")
    return

def examB():
    a, b, M = LI()
    A = LI()
    B = LI()
    D = [LI()for _ in range(M)]
    ans = min(A) + min(B)
    for x,y,c in D:
        cur = A[x-1]+B[y-1]-c
        ans = min(ans,cur)
    print(ans)
    return

def examC():
    def bfs(n, e, fordfs):
        # 点の数、スタートの点、有向グラフ
        W = [-1] * n
        # 各点の状態量、最短距離とか,見たかどうかとか
        W[e] = 0
        que = deque()
        que.append(e)
        while que:
            now = que.popleft()
            nowW = W[now]
            for ne in fordfs[now]:
                if W[ne] == -1:
                    W[ne] = nowW + 1
                    que.append(ne)
        return W
    N = I()
    V = [[]for _ in range(N)]
    for _ in range(N-1):
        a, b = LI()
        a -= 1
        b -= 1
        V[a].append(b)
        V[b].append(a)
    L = bfs(N,0,V)
    #print(L)
    odd = 0
    for l in L:
        if l==-1:
            print(-1)
            return
        if l%2==1:
            odd += 1
    G = []
    if odd*2<N:
        for i in range(N):
            if L[i]%2==1:
                G.append(i)
    else:
        for i in range(N):
            if L[i]%2==0:
                G.append(i)

    used = [False]*(N+1)
    ans = [0]*N
    if N//3>=len(G):
        cur = 3
        for g in G:
            ans[g] = cur
            used[cur] = True
            cur += 3
        cur = 1
        for i in range(N):
            if ans[i]!=0:
                continue
            while(used[cur]):
                cur += 1
            ans[i] = cur
            used[cur] = True
    else:
        cur = 1
        for g in G:
            ans[g] = cur
            used[cur] = True
            cur += 3
            if cur>N:
                cur = 3
        cur = 1
        for i in range(N):
            if ans[i]!=0:
                continue
            while(used[cur]):
                cur += 1
            ans[i] = cur
            used[cur] = True
    print(" ".join(map(str,ans)))
    return

def examD():
    N, T = LI()


    ans = 0
    print(ans)
    return

def examE():
    N, M = LI()
    H = 2**N-1; W = 2**M -1
    ans = [[0]*W for _ in range(H)]
    for h in range(H):
        for w in range(W):
            if not (h%2)==(w%2)==1:
                ans[h][w] = 1
    for v in ans:
        print("".join(map(str,v)))
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examE()

"""

"""

Submission status: Wrong Answer

Solution code:
N, M = map(int, raw_input().split())

is_ordi = True
array1 = ""
array2 = ""
for i in range(2**(N-1)):
    array1 = array1+"10"
    array2 = array2+"01"

array1 = array1[:-1]
array2 = array2[:-1]

for i in range(2**N-1):
    if i%2 == 0:
        print array1
    else:
        print array2

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

for i in range(2**n-1):
    for j in range(2**m-1):
        print(1, end='')
    print()

Submission status: Wrong Answer

Solution code:
N, M = (int(i) for i in input().split())
for i in range(2**N-1):
    print(" ".join([str(int((j%2)^(i%2)^1)) for j in range(2**M-1)]))

Submission status: Wrong Answer

Solution code:
n, m = [int(x) for x in input().split()]
for j in range(2 ** n - 1):
    print('1' * (2 ** m - 1))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
ans = [[0 for j in range(2**m-1)] for i in range(2**n-1)]
for i in range(2**n-1):
  for j in range(2**m-1):
    if i%2 != j%2:
      ans[i][j] = 1
    elif i%2 == 0:
      ans[i][j] = 1
for arr in ans:
  print(*arr,sep="")

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())

ans = [[] for i in range(2**N-1)]

for i in range(2**N-1):
    for j in range(2**M-1):
        if i%2==0 and j%2==0:
            ans[i].append(1)
        elif i%2==1 and j%2==1:
            ans[i].append(1)
        else:
            ans[i].append(0)

for i in ans:
    print(''.join(map(str, i)))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
ans = [[0 for j in range(2**m-1)] for i in range(2**n-1)]
for i in range(2**n-1):
  for j in range(2**m-1):
    if i%2 == j%2:
      ans[i][j] = 1
for arr in ans:
  print(*arr,sep="")

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())

for i in range(2**n-1):
    if i % 2 == 0:
        print("1"*(2**m-1))
    else:
        print("10"*(2**(m-1)-1)+"1")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,M = inpl()
H = 2**N-1
W = 2**M-1

ans = [[-1] * W for _ in range(H)]
for i in range(W):
    for j in range(H):
        ans[j][i] = (i%2)^(j%2)


for a in ans:
    print("".join(map(str,a)))

Submission status: Wrong Answer

Solution code:
def examA():
    S = SI()
    if len(S)%2==1:
        print("No")
        return
    for i in range(len(S)//2):
        if S[i*2:i*2+2]!="hi":
            print("No")
            return
    print("Yes")
    return

def examB():
    a, b, M = LI()
    A = LI()
    B = LI()
    D = [LI()for _ in range(M)]
    ans = min(A) + min(B)
    for x,y,c in D:
        cur = A[x-1]+B[y-1]-c
        ans = min(ans,cur)
    print(ans)
    return

def examC():
    def bfs(n, e, fordfs):
        # 点の数、スタートの点、有向グラフ
        W = [-1] * n
        # 各点の状態量、最短距離とか,見たかどうかとか
        W[e] = 0
        que = deque()
        que.append(e)
        while que:
            now = que.popleft()
            nowW = W[now]
            for ne in fordfs[now]:
                if W[ne] == -1:
                    W[ne] = nowW + 1
                    que.append(ne)
        return W
    N = I()
    V = [[]for _ in range(N)]
    for _ in range(N-1):
        a, b = LI()
        a -= 1
        b -= 1
        V[a].append(b)
        V[b].append(a)
    L = bfs(N,0,V)
    #print(L)
    odd = 0
    for l in L:
        if l==-1:
            print(-1)
            return
        if l%2==1:
            odd += 1
    G = []
    if odd*2<N:
        for i in range(N):
            if L[i]%2==1:
                G.append(i)
    else:
        for i in range(N):
            if L[i]%2==0:
                G.append(i)

    used = [False]*(N+1)
    ans = [0]*N
    if N//3>=len(G):
        cur = 3
        for g in G:
            ans[g] = cur
            used[cur] = True
            cur += 3
        cur = 1
        for i in range(N):
            if ans[i]!=0:
                continue
            while(used[cur]):
                cur += 1
            ans[i] = cur
            used[cur] = True
    else:
        cur = 1
        for g in G:
            ans[g] = cur
            used[cur] = True
            cur += 3
            if cur>N:
                cur = 3
        cur = 1
        for i in range(N):
            if ans[i]!=0:
                continue
            while(used[cur]):
                cur += 1
            ans[i] = cur
            used[cur] = True
    print(" ".join(map(str,ans)))
    return

def examD():
    N, T = LI()


    ans = 0
    print(ans)
    return

def examE():
    N, M = LI()
    H = 2**N-1; W = 2**M -1
    ans = [[0]*W for _ in range(H)]
    for h in range(H):
        for w in range(W):
            #if (h%2)==(w%2):
            ans[h][w] = 1
    for v in ans:
        print("".join(map(str,v)))
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examE()

"""

"""

Submission status: Wrong Answer

Solution code:
def examA():
    S = SI()
    if len(S)%2==1:
        print("No")
        return
    for i in range(len(S)//2):
        if S[i*2:i*2+2]!="hi":
            print("No")
            return
    print("Yes")
    return

def examB():
    a, b, M = LI()
    A = LI()
    B = LI()
    D = [LI()for _ in range(M)]
    ans = min(A) + min(B)
    for x,y,c in D:
        cur = A[x-1]+B[y-1]-c
        ans = min(ans,cur)
    print(ans)
    return

def examC():
    def bfs(n, e, fordfs):
        # 点の数、スタートの点、有向グラフ
        W = [-1] * n
        # 各点の状態量、最短距離とか,見たかどうかとか
        W[e] = 0
        que = deque()
        que.append(e)
        while que:
            now = que.popleft()
            nowW = W[now]
            for ne in fordfs[now]:
                if W[ne] == -1:
                    W[ne] = nowW + 1
                    que.append(ne)
        return W
    N = I()
    V = [[]for _ in range(N)]
    for _ in range(N-1):
        a, b = LI()
        a -= 1
        b -= 1
        V[a].append(b)
        V[b].append(a)
    L = bfs(N,0,V)
    #print(L)
    odd = 0
    for l in L:
        if l==-1:
            print(-1)
            return
        if l%2==1:
            odd += 1
    G = []
    if odd*2<N:
        for i in range(N):
            if L[i]%2==1:
                G.append(i)
    else:
        for i in range(N):
            if L[i]%2==0:
                G.append(i)

    used = [False]*(N+1)
    ans = [0]*N
    if N//3>=len(G):
        cur = 3
        for g in G:
            ans[g] = cur
            used[cur] = True
            cur += 3
        cur = 1
        for i in range(N):
            if ans[i]!=0:
                continue
            while(used[cur]):
                cur += 1
            ans[i] = cur
            used[cur] = True
    else:
        cur = 1
        for g in G:
            ans[g] = cur
            used[cur] = True
            cur += 3
            if cur>N:
                cur = 3
        cur = 1
        for i in range(N):
            if ans[i]!=0:
                continue
            while(used[cur]):
                cur += 1
            ans[i] = cur
            used[cur] = True
    print(" ".join(map(str,ans)))
    return

def examD():
    N, T = LI()


    ans = 0
    print(ans)
    return

def examE():
    N, M = LI()
    H = 2**N-1; W = 2**M -1
    ans = [[0]*W for _ in range(H)]
    for h in range(H):
        for w in range(W):
            if (h%2)==(w%2):
                ans[h][w] = 1
    for v in ans:
        print("".join(map(str,v)))
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examE()

"""

"""

Submission status: Wrong Answer

Solution code:
N, M = (int(i) for i in input().split())
for i in range(2**N - 1):
    print("".join(["1"] * (2**M - 1)))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
X, Y = 2 ** N - 1, 2 ** M - 1
for i in range(X):
  if i % 2 == 0:
    for j in range(Y):
      print(1, end = '')
    print()
  elif i % 2 == 1:
    for j in range(Y):
      if j % 2 == 0:
        print(1, end = '')
      else:
        print(0, end = '')
    print()

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
s=["10"*(2**n-1)+"1","01"*(2**n-1)+"0"]
for i in range(2**n-1):
  print(s[i%2])

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
for i in range(2**n-1):
    if i%2==0:
        for j in range(2**(m-1)-1):
            print(10,end="")
        print(1)
    else:
        for j in range(2**(m-1)-1):
            print("01",end="")
        print(0)

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
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)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def f(s):
        res = 0
        for i1 in range(h):
            for i2 in range(i1,h):
                for j1 in range(w):
                    for j2 in range(j1,w):
                        su = 0
                        for k in range(i1,i2+1):
                            for l in range(j1,j2+1):
                                su ^= s[k][l]
                        if su:
                            res += 1
        return res
    n,m = LI()
    h,w = (1<<n)-1, (1<<m)-1
    ans = 0
    """
    p = [[]]
    for b in range(1<<(h*w)):
        s = [[1 if b&1<<(j+i*w) else 0 for j in range(w)] for i in range(h)]
        fs = f(s)
        if ans <= fs:
            ans = fs
            p = [[i for i in j] for j in s]
    for i in p:
        print(i)
    print(ans)
    """
    if h == 1:
        print(*[1]*w,sep = " ")
    elif w == 1:
        for i in range(h):
            print(1)
    else:
        ans = [[1]*w for i in range(h)]
        ans[h>>1][w>>1] = 0
        for i in range(h):
            print(*ans[i])
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
for i in range(2**n-1):
    if i%2==0:
        for j in range(2**(m-1)-1):
            print(10,end="")
        print(1)
    else:
        print("0"*(2**m-1))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
for i in range(2**n-1):
  print(bin(2**(2**m-1)-1)[2:])

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())

L1 = []
L2 = []
for i in range(2**M-1):
    L1.append(str((i+1)%2))
    L2.append(str(i%2))

for i in range(2**N-1):
    if i%2 == 0:
        print("".join(L1))
    else:
        print("".join(L2))

Submission status: Time Limit Exceeded

Solution code:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
import numpy as np
def resolve():
    N, M = lr()
    rev = 0
    if N < M:
        M, N = N, M
        rev = 1
    T = np.zeros(1, dtype=np.int8)
    for i in range(N):
        T = np.tile(T, (2, 2))
        T[1<<i:, 1<<i:] ^= 1
    T = np.diff(T, axis=0)
    T = np.diff(T, axis=1)
    T = T[:, :(1<<M)-1]%2
    if rev:
        T = np.transpose(T)
    for i in range(len(T)):
        print(*T[i], sep='')
resolve()

Submission status: Time Limit Exceeded

Solution code:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
import numpy as np
def resolve():
    N, M = lr()
    rev = 0
    if N < M:
        M, N = N, M
        rev = 1
    T = np.zeros((1<<M, 1<<N), dtype=np.int8)
    for i in range(1<<M):
        for j in range(1<<N):
            T[i][j] = bin(i&j).count("1")%2
    T = np.diff(T, axis=0)%2
    T = np.diff(T, axis=1)%2
    if not rev:
        T = np.transpose(T)
    for i in range(len(T)):
        print(*T[i], sep='')
resolve()

Submission status: Time Limit Exceeded

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N,M = map(int,read().split())

def solve(N,M):
    if N > M:
        return solve(M,N).T
    H = np.array([[0]], np.int8)
    for i in range(M):
        H = np.tile(H, (2,2))
        H[1<<i:,1<<i:] ^= 1
    H = np.diff(H, axis=0)
    H = np.diff(H, axis=1)
    return (H % 2)[:(1<<N) - 1]

H = solve(N,M)
rows = (''.join(map(str, row)) for row in H)
print('\n'.join(rows))

Submission status: Time Limit Exceeded

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N,M = map(int,read().split())

def solve(N,M):
    if N > M:
        return solve(M,N).T
    H = np.array([[0]], np.int8)
    for i in range(M):
        H = np.tile(H, (2,2))
        H[1<<i:,1<<i:] ^= 1
    H = np.diff(H, axis=0)
    H = np.diff(H, axis=1)
    return (H % 2)[:(1<<N) - 1]

H = solve(N,M)
rows = (''.join(map(str, row)) for row in H)
print('\n'.join(rows))

Submission status: Accepted

Solution code:
N,M=map(int,input().split())

A=[]
for i in range(2**N):
    B=[]
    for j in range(2**M):
        B.append(bin(i&j).count("1")%2)
    A.append(B)

ANS=[[0]*(2**M) for i in range(2**N)]

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

for a in ANS[1:]:
    print("".join(map(str,a[1:])))

Submission status: Accepted

Solution code:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
import numpy as np
def resolve():
    N, M = lr()
    rev = 0
    if N < M:
        M, N = N, M
        rev = 1
    T = np.zeros(1, dtype=np.int8)
    for i in range(N):
        T = np.tile(T, (2, 2))
        T[1<<i:, 1<<i:] ^= 1
    T = np.diff(T, axis=0)
    T = np.diff(T, axis=1)
    T = T[:, :(1<<M)-1]%2
    if rev:
        T = np.transpose(T)
    for t in T:
        print(''.join(t.astype(str)))
resolve()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ans = [0, 1]
for i in range(1, min(n, m)):
    k = 1 << i
    x = (1 << k) - 1
    slide = [a << k for a in ans]
    new_ans = [s | a for s, a in zip(slide, ans)]
    new_ans.extend(s | (a ^ x) for s, a in zip(slide, ans))
    ans = new_ans
if n > m:
    ans *= 1 << (n - m)
elif n < m:
    for i in range(n, m):
        k = 1 << i
        ans = [(a << k) | a for a in ans]

ans = [a0 ^ a1 for a0, a1 in zip(ans, ans[1:])]
ans = [a ^ (a >> 1) for a in ans]

print('\n'.join(map(('{:0' + str(2 ** m - 1) + 'b}').format, ans)))

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
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)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def hadamard(n):
        if mem[n] != None:
            return mem[n]
        h = hadamard(n-1)
        res = [[j for j in i] for i in h]
        res_ = [[j for j in i] for i in h]
        for i in range(len(res)):
            res[i] += [j for j in h[i]]
            res_[i] += [j^1 for j in h[i]]
        res += res_
        mem[n] = res
        return res

    n,m = LI()
    f = 0
    if m < n:
        n,m = m,n
        f = 1
    h,w = 1<<n, 1<<m
    mem = defaultdict(lambda : None)
    mem[0] = [[0]]
    s = hadamard(m)[:h]
    if f:
        s = [[s[j][i] for j in range(h)] for i in range(w)]
        h,w = w,h
    for x in range(w):
        for y in range(h-1)[::-1]:
            s[y+1][x] ^= s[y][x]
    for y in range(h):
        for x in range(w-1)[::-1]:
            s[y][x+1] ^= s[y][x]
    ans = [i[1:] for i in s[1:]]
    for i in ans:
        print(*i,sep="")
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
import sys

bitcnt = [0] * (1 << 10)
for i in range(1,1 << 10):
    bitcnt[i] = bitcnt[i//2] + i % 2
    bitcnt[i] %= 2

field = [[bitcnt[i & j] for j in range(1 << 10)] for i in range(1 << 10)]
    
n, m = map(int, input().split())
n = 1 << n
m = 1 << m
for i in range(1, n):
    for j in range(1, m):
        num = field[i][j] - field[i-1][j-1] - field[i-1][j] -field[i][j-1]
        sys.stdout.write(str(num%2))
    print()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

n,m = [int(i) for i in read().split()]


def popcount(i): # i < 2^32
    i = i - ((i >> 1) & 0x55555555)
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333)
    return (((i + (i >> 4) & 0xF0F0F0F) * 0x1010101) & 0xffffffff) >> 24

N = 2**n
M = 2**m
a = []
for k in range(N):
    a.append([popcount(x&k)&1 for x in range(M)])

#print(a)
for i in range(N-1,0,-1):
    for j in range(M-1,0,-1):
        a[i][j] ^= a[i-1][j]^a[i][j-1]^a[i-1][j-1]

for i in range(1,N):
    x = map(str,a[i][1:])
    print("".join(x))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ans=[["1"]*(2**m-1) for _ in range(2**n-1)]
for k in range(1,11):
    for i in range(2**k,2**n,2**k):
        for j in range(2**k,2**m,2**k):
            if ans[i-1][j-1]=="1":
                ans[i-1][j-1]="0"
            else:
                ans[i-1][j-1]="1"
for i in range(2**n-1):
    print("".join(ans[i]))

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N,M = map(int,read().split())

def solve(N,M):
    if N > M:
        return solve(M,N).T
    H = np.array([[0]], np.int8)
    for i in range(M):
        H = np.tile(H, (2,2))
        H[1<<i:,1<<i:] ^= 1
    H = np.diff(H, axis=0)
    H = np.diff(H, axis=1)
    return (H % 2)[:(1<<N) - 1]

H = solve(N,M)
size = 0
for row in H:
    word = ''.join(row.astype(str))
    print(word)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())

for in range(N):
    for j in range(M):
        print(1, end=" ")
    print()

Submission status: Runtime Error

Solution code:
def solve(n, m):
    
    if m == 1:
        s1 = "1"
        s2 = "1"
        s0 = "1"
    elif m == 2:
        s1 = "111"
        s2 = "101"
        s0 = "000"
    else:
        s1 = "1" + "0" * (2 ** (m - 1) - 2) + "1" + "0" * (2 ** (m - 1) - 2) + "1"
        s0 = "0" * (2 ** m - 1)
        s2 = "1" + "0" * (2 ** m - 3) + "1"
        
    if n == 1:
        return [s1]
  
    for i in range(2 ** n - 1):
        if i == 0:
            s = s1
        elif i == 2 ** n - 2
            s = s1
        elif:
            s = s2
        else:
            s = s0
        res.append(s)
    return res


def main():
    n, m = map(int, input().split())
    res = solve(n, m)
    for r in res:
        print(r)


def test():
    assert solve() == 0
    assert solve() == 0
    assert solve() == 0


if __name__ == "__main__":
    # test()
    main()

Submission status: Runtime Error

Solution code:
N, M = list(map(int, input().split()))

if M == 2:
  x = 0/0

L = [0] * (2 ** M - 1)
L[0] = 1
L[-1] = 1
R = [0] * (2 ** M - 1)

for i in range(2 ** N - 1):
  if i == 0 or i == 2 ** N - 2:
    print("".join(list(map(str, L))))
  else:
    print("".join(list(map(str, R))))

Submission status: Runtime Error

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M=MI()
    if(2 in (N,M)):
        raise Exception
    N=2**N-1
    M=2**M-1
    
    ans = [[1 if j&1 else (i&1)^1 for i in range(M)] for j in range(N)]
    for a in ans:
        print(*a,sep="")
    
if __name__ == '__main__':
    main()