From 88e542c98276dac30184ad34bb2aa0b2945aa59c Mon Sep 17 00:00:00 2001 From: Segcolt <9hmbzr275@mozmail.com> Date: Sun, 17 Nov 2024 16:16:54 -0300 Subject: [PATCH] Change the solution to be more simple. The logic was much more simple than what I could have thought on the contest... --- .../C. Superultra's Favorite Permutation.cpp | 51 +++++-------------- 1 file changed, 12 insertions(+), 39 deletions(-) diff --git a/Codeforces Round 988 (Div. 3)/C. Superultra's Favorite Permutation.cpp b/Codeforces Round 988 (Div. 3)/C. Superultra's Favorite Permutation.cpp index 8cfe93c..9d6f0df 100644 --- a/Codeforces Round 988 (Div. 3)/C. Superultra's Favorite Permutation.cpp +++ b/Codeforces Round 988 (Div. 3)/C. Superultra's Favorite Permutation.cpp @@ -74,25 +74,17 @@ int main() ios::sync_with_stdio(false); cin.tie(nullptr); - V isprime(1e5 * 4 + 1, true); - isprime[1] = false; - - for (size_t i = 1; i <= (size_t)1e5 * 4; i++) { - if (!isprime[i]) { - continue; - } - - for (size_t j = i * 2; j <= (size_t)1e5 * 4; j += i) { - isprime[j] = false; - } - } - int t; cin >> t; while (t--) { int n; cin >> n; + if (n <= 4) { + cout << "-1\n"; + continue; + } + vi odd; vi even; @@ -104,35 +96,16 @@ int main() } } - int i = odd.size() - 1; - int j = 0; - - while (i >= 0) { - j = even.size() - 1; - while (j >= 0 && isprime[odd[i] + even[j]]) { - j--; - } - if (j >= 0) { - break; - } - i--; - } - - if (i < 0) { - cout << "-1\n"; - continue; - } - - for (size_t k = 0; k < odd.size(); k++) { - if (k != i) { - cout << odd[k] << ' '; + repv(i, odd) { + if (i != 5) { + cout << i << ' '; } } - cout << odd[i] << ' ' << even[j] << ' '; - for (size_t k = 0; k < even.size(); k++) { - if (k != j) { - cout << even[k] << ' '; + cout << "5 4 "; + repv(i, even) { + if (i != 4) { + cout << i << ' '; } } cout << '\n';