結果

問題 No.2719 Equal Inner Products in Permutation
ユーザー PNJPNJ
提出日時 2024-04-05 22:25:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 184 ms / 2,000 ms
コード長 1,077 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 154,460 KB
最終ジャッジ日時 2024-04-05 22:25:58
合計ジャッジ時間 7,436 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 AC 36 ms
53,460 KB
testcase_05 AC 37 ms
53,460 KB
testcase_06 AC 37 ms
53,460 KB
testcase_07 AC 40 ms
53,460 KB
testcase_08 AC 37 ms
53,460 KB
testcase_09 AC 37 ms
53,460 KB
testcase_10 AC 51 ms
64,420 KB
testcase_11 AC 52 ms
66,516 KB
testcase_12 AC 51 ms
64,420 KB
testcase_13 AC 50 ms
64,428 KB
testcase_14 AC 53 ms
66,512 KB
testcase_15 AC 163 ms
141,316 KB
testcase_16 AC 162 ms
147,368 KB
testcase_17 AC 130 ms
118,628 KB
testcase_18 AC 168 ms
151,040 KB
testcase_19 AC 156 ms
136,220 KB
testcase_20 AC 121 ms
114,396 KB
testcase_21 AC 170 ms
151,132 KB
testcase_22 AC 138 ms
128,392 KB
testcase_23 AC 137 ms
122,512 KB
testcase_24 AC 119 ms
113,100 KB
testcase_25 AC 164 ms
151,784 KB
testcase_26 AC 168 ms
154,460 KB
testcase_27 AC 184 ms
152,732 KB
testcase_28 AC 168 ms
152,520 KB
testcase_29 AC 167 ms
151,780 KB
testcase_30 AC 180 ms
154,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
if N == 1:
  print(-1)
  exit()

if N % 4 == 0:
  P = []
  Q = []
  R = []
  for i in range(N):
    if i % 4 == 0 or i % 4 == 3:
      P.append(3*i + 1)
      R.append(3*i + 2)
    else:
      P.append(3*i + 2)
      R.append(3*i + 1)
    Q.append(3*i + 3)

elif N % 4 == 1:
  P = [1,4,7,8,14]
  Q = [3,6,12,13,15]
  R = [5,2,10,11,9]
  for i in range(5,N):
    j = i - 5
    if j % 4 == 0 or j % 4 == 3:
      P.append(3*i + 1)
      R.append(3*i + 2)
    else:
      P.append(3*i + 2)
      R.append(3*i + 1)
    Q.append(3*i + 3)

elif N % 4 == 2:
  P = [1,4]
  Q = [3,6]
  R = [5,2]
  for i in range(2,N):
    j = i - 2
    if j % 4 == 0 or j % 4 == 3:
      P.append(3*i + 1)
      R.append(3*i + 2)
    else:
      P.append(3*i + 2)
      R.append(3*i + 1)
    Q.append(3*i + 3)

else:
  P = [1,2,8]
  Q = [3,6,9]
  R = [7,5,4]
  for i in range(3,N):
    j = i - 3
    if j % 4 == 0 or j % 4 == 3:
      P.append(3*i + 1)
      R.append(3*i + 2)
    else:
      P.append(3*i + 2)
      R.append(3*i + 1)
    Q.append(3*i + 3)

ans = P + Q + R
print(*ans)
0