結果

問題 No.2719 Equal Inner Products in Permutation
ユーザー KudeKude
提出日時 2024-04-05 22:44:38
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 1,637 bytes
コンパイル時間 3,381 ms
コンパイル使用メモリ 276,360 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-05 22:44:47
合計ジャッジ時間 8,270 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 3 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 35 ms
6,676 KB
testcase_16 AC 38 ms
6,676 KB
testcase_17 AC 24 ms
6,676 KB
testcase_18 AC 39 ms
6,676 KB
testcase_19 AC 33 ms
6,676 KB
testcase_20 AC 23 ms
6,676 KB
testcase_21 AC 40 ms
6,676 KB
testcase_22 AC 29 ms
6,676 KB
testcase_23 AC 26 ms
6,676 KB
testcase_24 AC 22 ms
6,676 KB
testcase_25 AC 40 ms
6,676 KB
testcase_26 AC 42 ms
6,676 KB
testcase_27 AC 40 ms
6,676 KB
testcase_28 AC 41 ms
6,676 KB
testcase_29 AC 41 ms
6,676 KB
testcase_30 AC 41 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

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