結果

問題 No.2719 Equal Inner Products in Permutation
ユーザー ecotteaecottea
提出日時 2024-02-10 17:00:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 499 ms / 2,000 ms
コード長 1,198 bytes
コンパイル時間 321 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 43,020 KB
最終ジャッジ日時 2024-02-10 17:00:23
合計ジャッジ時間 12,035 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,112 KB
testcase_01 AC 27 ms
10,112 KB
testcase_02 AC 28 ms
10,112 KB
testcase_03 AC 28 ms
10,112 KB
testcase_04 AC 28 ms
10,112 KB
testcase_05 AC 27 ms
10,112 KB
testcase_06 AC 31 ms
10,112 KB
testcase_07 AC 27 ms
10,112 KB
testcase_08 AC 28 ms
10,112 KB
testcase_09 AC 28 ms
10,112 KB
testcase_10 AC 31 ms
10,624 KB
testcase_11 AC 32 ms
10,624 KB
testcase_12 AC 32 ms
10,624 KB
testcase_13 AC 30 ms
10,624 KB
testcase_14 AC 33 ms
10,624 KB
testcase_15 AC 405 ms
37,776 KB
testcase_16 AC 464 ms
41,400 KB
testcase_17 AC 299 ms
29,476 KB
testcase_18 AC 462 ms
41,748 KB
testcase_19 AC 385 ms
36,252 KB
testcase_20 AC 263 ms
27,724 KB
testcase_21 AC 483 ms
41,944 KB
testcase_22 AC 341 ms
32,788 KB
testcase_23 AC 304 ms
30,904 KB
testcase_24 AC 259 ms
27,220 KB
testcase_25 AC 468 ms
43,020 KB
testcase_26 AC 494 ms
43,020 KB
testcase_27 AC 462 ms
43,020 KB
testcase_28 AC 499 ms
43,020 KB
testcase_29 AC 476 ms
43,020 KB
testcase_30 AC 493 ms
43,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#(別解)長さ 4 の基本パターンを連結していく方法

n = int(input())

if n == 1:
    print(-1)
    exit(0)

a2 = [1, 4]
b2 = [3, 6]
c2 = [5, 2]
a3 = [1, 2, 8]
b3 = [3, 6, 9]
c3 = [7, 5, 4]
a4 = [1, 2, 4, 11]
b4 = [7, 9, 10, 12]
c4 = [8, 5, 6, 3]
a5 = [1, 2, 3, 8, 13] # これを見つけるのがややしんどい
b5 = [7, 10, 12, 14, 15]
c5 = [11, 9, 6, 4, 5]

if n % 4 == 2:
    a = a2.copy()
    b = b2.copy()
    c = c2.copy()
elif n % 4 == 3:
    a = a3.copy()
    b = b3.copy()
    c = c3.copy()
elif n % 4 == 0:
    a = a4.copy()
    b = b4.copy()
    c = c4.copy()
else:
    a = a5.copy()
    b = b5.copy()
    c = c5.copy()

l = len(a)

for i in range(3 * l + 1, 2 * l + n + 1):
    b.append(i)

for i in range(2 * (n - l)):
    if i % 8 == 0 or i % 8 == 3 or i % 8 == 5 or i % 8 == 6:
        a.append(2 * l + n + 1 + i)
    else:
        c.append(2 * l + n + 1 + i)

# print(a)
# print(b)
# print(c)

# N = 10 の例
# [1, 4,  15, 18, 20, 21,  23, 26, 28, 29]
# [3, 6,   7,  8,  9, 10,  11, 12, 13, 14]
# [5, 2,  16, 17, 19, 22,  24, 25, 27, 30]

# l = 0
# r = 0
# for i in range(n):
#     l += a[i] * b[i]
#     r += b[i] * c[i]
# print(l, r)

print(*(a + b + c))
0