fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void solve() {
  5. int n;
  6. cin >> n;
  7.  
  8. vector<int> a(n);
  9.  
  10. // Create a palindromic sequence with a repeating pattern
  11. for (int i = 0; i < n; i++) {
  12. a[i] = (i % 2) + 1; // Alternating between 1 and 2 ensures many palindromic subsequences
  13. }
  14.  
  15. for (int i = 0; i < n; i++) {
  16. cout << a[i] << " ";
  17. }
  18. cout << endl;
  19. }
  20.  
  21. int main() {
  22. ios_base::sync_with_stdio(false);
  23. cin.tie(NULL);
  24.  
  25. int t;
  26. cin >> t;
  27. while (t--) {
  28. solve();
  29. }
  30.  
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0.01s 5280KB
stdin
3
6
9
15
stdout
1 2 1 2 1 2 
1 2 1 2 1 2 1 2 1 
1 2 1 2 1 2 1 2 1 2 1 2 1 2 1