結果

問題 No.3739 Stronger Network
コンテスト
ユーザー toka0428
提出日時 2026-09-19 17:49:23
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 785 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 66 ms
コンパイル使用メモリ 82,412 KB
実行使用メモリ 131,276 KB
最終ジャッジ日時 2026-09-19 17:49:34
合計ジャッジ時間 6,005 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25 WA * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def ar(N):
  A = [0]
  k = 0
  a = 1
  while 2*a <= N:
    for i in range(a-1,-1,-1):
      A.append(A[i]^(2**k))
    k += 1
    a *= 2
  X = N - len(A)  
  B = []
  for i in range(0,len(A),2):
    if A[i] < X:
      B += [A[i],A[i]^(2**k),A[i+1]^(2**k),A[i+1]]
    else:
      B += [A[i],A[i+1]]
  return B

H,W = map(int,input().split())
if H % 2 != 0 or W % 2 != 0:
  print(-1)
else:
  h = 0
  while 2**h < H:
    h += 1
  w = 0
  while 2**w < W:
    w += 1
  ans = [[-1 for j in range(W)] for i in range(H)]  
  A = ar(H)
  B = ar(W)
  if (H-1)*(2**w)+H <= (W-1)*(2**h)+W:
    for i in range(H):
      for j in range(W):
        ans[i][j] = A[i]*(2**w)+B[j]
  else:
    for i in range(H):
      for j in range(W):
        ans[i][j] = A[i]+B[j]*(2**h)
  for i in ans:
    print(*i)
0