結果

問題 No.2719 Equal Inner Products in Permutation
ユーザー PNJ
提出日時 2024-04-05 22:25:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 204 ms / 2,000 ms
コード長 1,077 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 82,524 KB
実行使用メモリ 154,368 KB
最終ジャッジ日時 2024-10-01 02:38:20
合計ジャッジ時間 7,540 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

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