結果

問題 No.1519 Diversity
ユーザー shotoyooshotoyoo
提出日時 2021-05-28 20:50:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 690 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 82,816 KB
最終ジャッジ日時 2024-04-24 23:08:34
合計ジャッジ時間 2,575 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
51,968 KB
testcase_01 AC 37 ms
52,608 KB
testcase_02 AC 40 ms
51,968 KB
testcase_03 AC 73 ms
77,952 KB
testcase_04 AC 95 ms
80,640 KB
testcase_05 AC 40 ms
52,224 KB
testcase_06 AC 97 ms
82,304 KB
testcase_07 AC 36 ms
52,608 KB
testcase_08 AC 67 ms
76,544 KB
testcase_09 AC 76 ms
78,336 KB
testcase_10 AC 85 ms
80,256 KB
testcase_11 AC 38 ms
52,096 KB
testcase_12 AC 100 ms
82,048 KB
testcase_13 AC 98 ms
82,432 KB
testcase_14 AC 93 ms
82,816 KB
testcase_15 AC 92 ms
82,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


n = int(input())
es = []
ds = [0]*n
for i in range(n-2, 0, -1):
#     print(i, ds[i], es)
    if ds[i]>=i:
        break
    ds[i] += 1
    ds[n-1] += 1
    es.append((i,n-1))
    j = i-1
    assert i!=n-1
    while ds[i]<i:
        es.append((j,i))
        assert i!=j
        ds[i] += 1
        ds[j] += 1
        j -= 1
assert len(set(ds))==n-1
if n==2:
    es = [(0,1)]
print(len(es))
write("\n".join([" ".join(map(str, [v+1 for v in item])) for item in es]))
0