結果

問題 No.2719 Equal Inner Products in Permutation
ユーザー flygonflygon
提出日時 2024-04-06 14:12:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 798 bytes
コンパイル時間 429 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 130,920 KB
最終ジャッジ日時 2024-04-06 14:12:31
合計ジャッジ時間 8,561 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
55,724 KB
testcase_01 AC 44 ms
55,724 KB
testcase_02 WA -
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 48 ms
55,724 KB
testcase_07 AC 45 ms
55,724 KB
testcase_08 AC 45 ms
55,724 KB
testcase_09 AC 44 ms
55,724 KB
testcase_10 AC 61 ms
68,740 KB
testcase_11 AC 61 ms
68,740 KB
testcase_12 AC 61 ms
68,740 KB
testcase_13 AC 60 ms
66,640 KB
testcase_14 AC 62 ms
68,740 KB
testcase_15 AC 167 ms
130,920 KB
testcase_16 AC 197 ms
129,164 KB
testcase_17 AC 138 ms
114,168 KB
testcase_18 AC 170 ms
128,932 KB
testcase_19 AC 156 ms
126,244 KB
testcase_20 AC 134 ms
110,236 KB
testcase_21 AC 170 ms
129,112 KB
testcase_22 AC 148 ms
119,984 KB
testcase_23 AC 142 ms
115,868 KB
testcase_24 AC 135 ms
109,336 KB
testcase_25 AC 174 ms
129,964 KB
testcase_26 AC 171 ms
129,964 KB
testcase_27 AC 175 ms
129,964 KB
testcase_28 AC 171 ms
129,964 KB
testcase_29 AC 171 ms
129,964 KB
testcase_30 AC 175 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 or n == 2:
    print(-1)
    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