結果

問題 No.2719 Equal Inner Products in Permutation
ユーザー Kude
提出日時 2024-04-05 22:44:38
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 1,637 bytes
コンパイル時間 3,530 ms
コンパイル使用メモリ 275,884 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-01 02:50:57
合計ジャッジ時間 8,107 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic warning "-Wunused-function"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;

} int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  if (n == 1) {
    cout << -1 << '\n';
    return 0;
  }
  VI a[3];
  if (n % 4 == 1) {
    a[0] = {1,2,3,13,15};
    a[1] = {4,5,7,12,14};
    a[2] = {6,8,9,10,11};
  } else if (n % 4 == 2) {
    a[0] = {1,6};
    a[1] = {2,4};
    a[2] = {3,5};
  } else if (n % 4 == 3) {
    a[0] = {1,2,9};
    a[1] = {5,7,8};
    a[2] = {3,4,6};
  }
  int j = a[0].size();
  int v = 3 * j + 1;
  while (ssize(a[0]) < n) {
    a[1].emplace_back(v++);
    a[0].emplace_back(v++);
    a[2].emplace_back(v++);
    a[1].emplace_back(v++);
    a[2].emplace_back(v++);
    a[0].emplace_back(v++);
    a[1].emplace_back(v++);
    a[2].emplace_back(v++);
    a[0].emplace_back(v++);
    a[1].emplace_back(v++);
    a[0].emplace_back(v++);
    a[2].emplace_back(v++);
  }
  rep(i, 3) rep(j, n) cout << a[i][j] << " \n"[i == 2 && j + 1 == n];
}
0