fork download
  1. /* Shubhulol */
  2.  
  3. //Header files
  4. #include <bits/stdc++.h>
  5. #include <ext/pb_ds/assoc_container.hpp>
  6. #include <ext/pb_ds/tree_policy.hpp>
  7. #include <functional>
  8.  
  9. //Macros
  10. #define ll long long
  11. #define ld long double
  12. #define db double
  13. #define str string
  14. #define lli long long int
  15. #define ull unsigned long long
  16. #define f(i,x,n) for(ll int i=x;i<n;i++)
  17. #define re(j,x,n) for(ll int j=x;j>=n;j--)
  18. #define f1(k,x,n) for(ll int k=x;k<=n;k++)
  19. #define mp(x,y) std::make_pair(string(x),int(y))
  20. #define pb push_back
  21. #define input file();
  22. #define bit(x, i) (x >>(i - 1) & 1ll)
  23. #define w() int x; cin>>x; while(x--)
  24. #define all(v) (v).begin(),(v).end()
  25. #define MAX 1000001
  26. #define nl '\n';
  27. #define c1(x) cin>>x;
  28. #define c2(x,s) cin>>x>>s;
  29. #define o1(x) cout<<x<<'\n';
  30. #define o2(x,y) cout<<x<<" "<<y<<'\n';
  31. #define o3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n';
  32. #define o4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<'\n';
  33.  
  34. //Variables
  35. const ll MOD = 1e9 + 7;
  36. const ll max = 1000000;
  37. int inf = 0x3f3f3f3f;
  38. ll infl = 0x3f3f3f3f3f3f3f3fLL;
  39. ld infd = 1.0 / 0.0;
  40.  
  41. //inclusion
  42. using namespace __gnu_pbds;
  43. using namespace std;
  44.  
  45. //Unordered ds
  46. typedef tree<pair<ll int, ll int>, null_type, less<pair<ll int, ll int> >, rb_tree_tag, tree_order_statistics_node_update>
  47. new_data_set;
  48.  
  49. //Input file
  50. void file() {
  51. #ifndef ONLINE_JUDGE
  52. freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
  53. #endif
  54. ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  55. }
  56.  
  57. void solve()
  58. {
  59. ll n = 0;
  60. //c1 input
  61. c1(n);
  62. //o1 output
  63. o1(n / 2);
  64. //special case
  65. if (n == 1) {
  66. o1(1);
  67. o2(1, 1);
  68. return;
  69. }
  70. f1(i, 1, n) {
  71. if (i == n)
  72. {
  73. o2(1, i);
  74. }
  75. else if (i == 1 && n >= 3) {
  76. o4(3, 1, 2, 3);
  77. i += 2;
  78. } else {
  79. o3(2, i, (i + 1));
  80. i += 1;
  81. }
  82. }
  83. }
  84.  
  85. int main()
  86. {
  87. input
  88. w() {
  89. solve();
  90. cout << nl;
  91. }
  92. return 0;
  93. }
  94.  
  95. // int main()
  96. // {
  97. // input
  98. // solve();
  99. // return 0;
  100. // }
  101.  
Success #stdin #stdout 0s 4560KB
stdin
1
15
stdout
7
3 1 2 3
2 4 5
2 6 7
2 8 9
2 10 11
2 12 13
2 14 15