Mahmoud_Hawara

Untitled

Nov 15th, 2024
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. #include <ext/pb_ds/tree_policy.hpp>
  4.  
  5. using namespace std;
  6. using namespace __gnu_pbds;
  7. using u64 = uint64_t;
  8. using u128 = __uint128_t;
  9.  
  10. #define ll long long
  11. #define ull unsigned long long
  12. #define ld long double
  13. #define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
  14. #define ordered_set tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
  15.  
  16. const int N = 5e5 + 5, M = 1e3 + 5, hb = 127, LOG = 25;
  17. const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1};
  18. const int dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};
  19. const ld PI = acos(-1), EPS = 1e-6;
  20. const ll MOD1 = 1e9 + 7, MOD2 = 998244353, OO = 1e15;
  21.  
  22. ll inv(ll a, ll b = MOD1)
  23. {
  24. return 1 < a ? b - inv(b % a, a) * b / a : 1;
  25. }
  26.  
  27. void solve()
  28. {
  29. ll n;
  30. cin >> n;
  31. if (n % 2)
  32. {
  33. if (n <= 25)
  34. {
  35. cout << "-1\n";
  36. return;
  37. }
  38. ll pos[n + 1] = {};
  39. pos[1] = pos[17] = pos[26] = 1;
  40. int j = 2;
  41. for (int i = 2; i <= 13; i += 2)
  42. {
  43. pos[i] = pos[i + 1] = j++;
  44. }
  45. pos[16] = pos[15] = j++;
  46. pos[18] = pos[14] = j++;
  47. pos[27] = pos[23] = j++;
  48. pos[24] = pos[25] = j++;
  49. pos[22] = pos[21] = j++;
  50. pos[20] = pos[19] = j++;
  51. for (int i = 28; i <= n; i += 2)
  52. {
  53. pos[i] = pos[i + 1] = j++;
  54. }
  55. for (int i = 1; i <= n; i++)
  56. {
  57. cout << pos[i] << ' ';
  58. }
  59. }
  60. else
  61. {
  62. for (int i = 1; i <= n / 2; i++)
  63. {
  64. cout << i << ' ' << i << ' ';
  65. }
  66. }
  67. cout << '\n';
  68. return;
  69. }
  70.  
  71. int main()
  72. {
  73. IO;
  74. // freopen("input.txt", "r", stdin);
  75. // freopen("output.txt", "w", stdout);
  76. int t = 1;
  77. cin >> t;
  78. while (t--)
  79. {
  80. solve();
  81. }
  82. return 0;
  83. }
  84.  
Advertisement
Add Comment
Please, Sign In to add comment