結果

問題 No.630 門松グラフ
ユーザー wajima_wataruwajima_wataru
提出日時 2018-01-05 22:48:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 200 ms / 1,500 ms
コード長 830 bytes
コンパイル時間 331 ms
コンパイル使用メモリ 10,820 KB
実行使用メモリ 12,688 KB
最終ジャッジ日時 2023-08-24 21:06:14
合計ジャッジ時間 5,037 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,276 KB
testcase_01 AC 16 ms
8,332 KB
testcase_02 AC 16 ms
8,348 KB
testcase_03 AC 15 ms
8,384 KB
testcase_04 AC 15 ms
8,408 KB
testcase_05 AC 16 ms
8,284 KB
testcase_06 AC 16 ms
8,244 KB
testcase_07 AC 16 ms
8,288 KB
testcase_08 AC 16 ms
8,336 KB
testcase_09 AC 16 ms
8,284 KB
testcase_10 AC 16 ms
8,360 KB
testcase_11 AC 16 ms
8,300 KB
testcase_12 AC 16 ms
8,340 KB
testcase_13 AC 15 ms
8,420 KB
testcase_14 AC 16 ms
8,276 KB
testcase_15 AC 15 ms
8,248 KB
testcase_16 AC 16 ms
8,448 KB
testcase_17 AC 15 ms
8,252 KB
testcase_18 AC 16 ms
8,408 KB
testcase_19 AC 16 ms
8,416 KB
testcase_20 AC 200 ms
12,688 KB
testcase_21 AC 15 ms
8,244 KB
testcase_22 AC 199 ms
12,572 KB
testcase_23 AC 15 ms
8,276 KB
testcase_24 AC 124 ms
8,452 KB
testcase_25 AC 16 ms
8,300 KB
testcase_26 AC 130 ms
8,476 KB
testcase_27 AC 125 ms
8,484 KB
testcase_28 AC 194 ms
12,372 KB
testcase_29 AC 167 ms
11,724 KB
testcase_30 AC 167 ms
10,848 KB
testcase_31 AC 152 ms
10,172 KB
testcase_32 AC 97 ms
10,048 KB
testcase_33 AC 77 ms
8,716 KB
testcase_34 AC 122 ms
9,816 KB
testcase_35 AC 90 ms
8,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
N, M = map(int, input().split())
if M < N - 1:
    print('NO')
    exit()    
if N % 2 == 0:
    if M > (N // 2) ** 2:
        print('NO')
        exit()
else:
    if M > (N // 2) * (N // 2 + 1):
        print('NO')
        exit()

print('YES')
for i in range(N):
    print(i + 1, end=' ')
print()
small = list(range(1, math.ceil(N / 2) + 1))
big = list(range(math.ceil(N / 2) + 1, N + 1))
count = 0
flg = True
s = 0
b = 0
while count < M:
    if flg:
        for n in big[b:]:
            print(str(small[s]) + ' ' + str(n))
            count += 1
            if count >= M:
                exit()
        s += 1
    else:
        for n in small[s:]:
            print(str(big[b]) + ' ' + str(n))
            count += 1
            if count >= M:
                exit()
        b += 1             
    flg = not(flg)
0