結果

問題 No.2797 Square Tile
コンテスト
ユーザー detteiuu
提出日時 2026-07-26 01:36:45
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 1,052 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 247 ms
コンパイル使用メモリ 96,104 KB
実行使用メモリ 92,032 KB
最終ジャッジ日時 2026-07-26 01:36:51
合計ジャッジ時間 4,014 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 13 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

A, B = map(int, input().split())

swap = False
if A < B:
    A, B = B, A
    swap = True

L = A**2+B**2

ansA = []
ansB = []

cnt = 0
S = set()
for i in range(L):
    h, w = A*cnt+i*B%L, i*A%L
    if (h, w) in S:
        cnt += 1
        h += A
        h %= L
    ansA.append((h, w))
    S.add((h, w))
cnt = 0
S = set()
for i in range(L):
    h, w = i*B%L, (A+B*cnt+i*A)%L
    while (h, w) in S:
        cnt += 1
        w += B
        w %= L
    ansB.append((h, w))
    S.add((h, w))

if swap:
    A, B = B, A
    ansA, ansB = ansB, ansA

for x, y in ansA:
    print(x, y)
for x, y in ansB:
    print(x, y)

#test
# ans = [["."]*L for _ in range(L)]
# for h, w in ansA:
#     for i in range(A):
#         for j in range(A):
#             if ans[(h+i)%L][(w+j)%L] != ".": print("NG(A)")
#             ans[(h+i)%L][(w+j)%L] = "o"
# for h, w in ansB:
#     for i in range(B):
#         for j in range(B):
#             if ans[(h+i)%L][(w+j)%L] != ".": print("NG(B)")
#             ans[(h+i)%L][(w+j)%L] = "x"
# for a in ans:
#     print("".join(a))
#test
0