結果

問題 No.2719 Equal Inner Products in Permutation
ユーザー ecotteaecottea
提出日時 2024-02-03 00:21:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 850 bytes
コンパイル時間 2,036 ms
コンパイル使用メモリ 207,292 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-08 17:18:58
合計ジャッジ時間 7,241 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 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 3 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 52 ms
6,676 KB
testcase_16 AC 58 ms
6,676 KB
testcase_17 AC 37 ms
6,676 KB
testcase_18 AC 59 ms
6,676 KB
testcase_19 AC 49 ms
6,676 KB
testcase_20 AC 35 ms
6,676 KB
testcase_21 AC 59 ms
6,676 KB
testcase_22 AC 43 ms
6,676 KB
testcase_23 AC 39 ms
6,676 KB
testcase_24 AC 33 ms
6,676 KB
testcase_25 AC 62 ms
6,676 KB
testcase_26 AC 61 ms
6,676 KB
testcase_27 AC 62 ms
6,676 KB
testcase_28 AC 61 ms
6,676 KB
testcase_29 AC 61 ms
6,676 KB
testcase_30 AC 62 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
using namespace std;


int main() {
	int n;
	cin >> n;

	if (n == 1) {
		cout << -1 << endl;
		return 0;
	}

	vector<int> a2{ 1, 4 }, b2{ 3, 6 }, c2{ 5, 2 };
	vector<int> a3{ 1, 2, 9 }, b3{ 6, 8, 7 }, c3{ 3, 4, 5 };
	vector<int> a4{ 1, 2, 4, 11 }, b4{ 7, 9, 10, 12 }, c4{ 8, 5, 6, 3 };

	vector<int> a, b, c;
	if (n % 3 == 2) a = a2, b = b2, c = c2;
	else if (n % 3 == 0) a = a3, b = b3, c = c3;
	else a = a4, b = b4, c = c4;

	int len = (int)a.size();
	while (len < n) {
		for (auto x : a3) a.push_back(x + 3 * len);
		for (auto x : b3) b.push_back(x + 3 * len);
		for (auto x : c3) c.push_back(x + 3 * len);
		len += 3;
	}

	for (int i = 0; i < n; i++) cout << a[i] << " ";
	for (int i = 0; i < n; i++) cout << b[i] << " ";
	for (int i = 0; i < n; i++) cout << c[i] << " \n"[i == n - 1];
}
0