結果

問題 No.2719 Equal Inner Products in Permutation
ユーザー ecotteaecottea
提出日時 2024-02-03 01:24:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 886 bytes
コンパイル時間 2,019 ms
コンパイル使用メモリ 207,152 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-08 17:19:09
合計ジャッジ時間 10,271 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;
	}

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