結果

問題 No.1519 Diversity
ユーザー paruf4
提出日時 2021-05-28 23:24:57
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 186 ms / 2,000 ms
コード長 428 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 16,256 KB
最終ジャッジ日時 2024-11-07 10:36:02
合計ジャッジ時間 2,871 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
c = [0]*(n+1)
cnt = n*(n-1)//2
cur = n
res = []
s = set()
while cnt > 0:
    tmp = cur-1-c[cur]
    for i in range(tmp):
        res.append((cur, cur-1-i))
        c[cur] += 1
        c[cur-1-i] += 1
        cnt -= 1
    for i in range(n, 0, -1):
        s.add(c[i])
    if len(s) == n-1:
        break
    cur -= 1
# print(c)
print(len(res))
for i in range(len(res)):
    a, b = res[i]
    print(n+1-a, n+1-b)
0