結果

問題 No.630 門松グラフ
ユーザー Akijin_007
提出日時 2023-10-06 14:22:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 585 bytes
コンパイル時間 427 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 95,104 KB
最終ジャッジ日時 2024-07-26 15:26:58
合計ジャッジ時間 8,049 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 2
other AC * 8 WA * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#int(input())
#map(int, input().split())
#list(map(int, input().split()))

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

a, b = divmod(N, 2)
if M < N-1 or M > a*(a+b):
    print("NO")
    exit()
else:
    print("YES")

a = [0] * N
for i in range(N):
    a[i] = (i % 2) + 1
print(" ".join([str(_) for _ in a]))

s = set()
for i in range(N-1):
    s.add((i, i+1))

M -= N-1
c = 0
while M:
    c += 1
    u, v = divmod(c, N)
    if u >= v:
        continue
    if (u+v) % 2 == 0:
        continue
    if (u, v) not in s:
        M -= 1
        s.add((u, v))

for x in s:
    print(x[0]+1, x[1]+1)



0