結果

問題 No.2719 Equal Inner Products in Permutation
ユーザー flygonflygon
提出日時 2024-04-06 14:13:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 174 ms / 2,000 ms
コード長 837 bytes
コンパイル時間 392 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 130,948 KB
最終ジャッジ日時 2024-04-06 14:13:53
合計ジャッジ時間 8,332 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
55,724 KB
testcase_01 AC 44 ms
55,724 KB
testcase_02 AC 45 ms
55,724 KB
testcase_03 AC 44 ms
55,724 KB
testcase_04 AC 43 ms
55,724 KB
testcase_05 AC 44 ms
55,724 KB
testcase_06 AC 45 ms
55,724 KB
testcase_07 AC 44 ms
55,724 KB
testcase_08 AC 44 ms
55,724 KB
testcase_09 AC 44 ms
55,724 KB
testcase_10 AC 59 ms
68,740 KB
testcase_11 AC 60 ms
68,740 KB
testcase_12 AC 59 ms
68,740 KB
testcase_13 AC 59 ms
66,640 KB
testcase_14 AC 61 ms
68,740 KB
testcase_15 AC 164 ms
130,948 KB
testcase_16 AC 168 ms
129,164 KB
testcase_17 AC 138 ms
114,168 KB
testcase_18 AC 171 ms
128,932 KB
testcase_19 AC 156 ms
126,268 KB
testcase_20 AC 131 ms
110,236 KB
testcase_21 AC 174 ms
129,112 KB
testcase_22 AC 146 ms
119,984 KB
testcase_23 AC 141 ms
115,868 KB
testcase_24 AC 129 ms
109,336 KB
testcase_25 AC 174 ms
129,964 KB
testcase_26 AC 174 ms
129,964 KB
testcase_27 AC 169 ms
129,964 KB
testcase_28 AC 170 ms
129,964 KB
testcase_29 AC 170 ms
129,964 KB
testcase_30 AC 171 ms
129,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd

n = int(input())
if n == 1:
    print(-1)
    exit()
elif n == 2:
    print(*[5,2,3,6,1,4])
    exit()
a = []
b = [i+1 for i in range(n)]
c = []
for i in range(n):
    x,y = n+2*i+1, n+2*i+2
    a.append(x)
    c.append(y)


if n % 4 == 1 or n % 4 == 2:
    a[-1], c[-2] = c[-2], a[-1]
    g = (n*(n+1)//2 + 2*n - 1)//2
else:
    g = (n*(n+1)//2)//2
now = 0
for i in range(n)[::-1]:
    x,y = a[i],c[i]
    if abs(b[i]*(a[i]-c[i]))+now <= g:
        now += abs(b[i]*(a[i]-c[i]))
        a[i] = min(x,y)
        c[i] = max(x,y)
    else:
        a[i] = max(x,y)
        c[i] = min(x,y)
ans = a+b+c

print(*ans)



0