fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long ll;
  5. typedef unsigned int ull;
  6. typedef long double lld;
  7.  
  8. /*---------------------------------------------------------------------------------------------------------------------------------------------*/
  9. #ifdef ONLINE_JUDGE
  10. #define debug(x)
  11. #pragma GCC optimize ("O3")
  12. #pragma GCC target ("sse4")
  13. #include <ext/pb_ds/tree_policy.hpp>
  14. #include <ext/pb_ds/assoc_container.hpp>
  15. #include <ext/rope>
  16. using namespace __gnu_pbds;
  17. using namespace __gnu_cxx;
  18.  
  19. #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
  20. #else
  21. #define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
  22. #endif
  23.  
  24. #define int long long
  25. #define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL)
  26. #define endl "\n"
  27. #define all(x) (x).begin(), (x).end()
  28. #define INF 1e18
  29. #define nline "\n"
  30. #define pb push_back
  31. #define ppb pop_back
  32. #define mp make_pair
  33. #define ff first
  34. #define ss second
  35. #define PI 3.141592653589793238462
  36. #define yes cout << "YES\n"
  37. #define no cout << "NO\n"
  38. #define setbits(x) __builtin_popcountll(x)
  39.  
  40. void _print(ll t) {cerr << t;}
  41. void _print(string t) {cerr << t;}
  42. void _print(char t) {cerr << t;}
  43. void _print(lld t) {cerr << t;}
  44. void _print(double t) {cerr << t;}
  45. void _print(ull t) {cerr << t;}
  46.  
  47. template <class T, class V> void _print(pair <T, V> p);
  48. template <class T> void _print(vector <T> v);
  49. template <class T> void _print(set <T> v);
  50. template <class T, class V> void _print(map <T, V> v);
  51. template <class T> void _print(multiset <T> v);
  52. template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}
  53. template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
  54. template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
  55. template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
  56. template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}
  57. /*---------------------------------------------------------------------------------------------------------------------------------------------*/
  58.  
  59. const int MAXN = 2e6;
  60. const int MOD = 1e9 + 7;
  61. int fac[MAXN + 1];
  62. int inv[MAXN + 1];
  63. int exp(int x,int n,int m){x%=m;int res = 1; while(n>0){if(n%2==1){res=res*x%m;}x=x*x%m;n/=2;}return res;}
  64. void factorial(){fac[0]=1;for(int i = 1; i <= MAXN; i++) { fac[i] = fac[i - 1] * i % MOD; }}
  65. void inverses() {inv[MAXN] = exp(fac[MAXN], MOD - 2, MOD);for (int i = MAXN; i >= 1; i--) { inv[i - 1] = inv[i] * i % MOD; }}
  66. int choose(int n, int r) { if(r>n)return 0ll;return (fac[n] * inv[r] % MOD * inv[n - r] % MOD)%MOD;}
  67.  
  68. // int div(int a,int b,int m){
  69. // return ((a%m)*(bin(b,m-2,m)%m))%m ;
  70. // }
  71.  
  72. void solve(){
  73. int n; cin >> n;
  74. vector<vector<int>> v(n,vector<int>(n));
  75. vector<int> ans;
  76. vector<int> k;
  77. for(int i=1;i<=n;i++){
  78. k.push_back(i);
  79. }
  80.  
  81. for(int i=0;i<n;i++){
  82. int c = i+1;
  83. for(int j=0;j<i+1;j++){
  84. v[i][j] = c;
  85. }
  86. }
  87.  
  88.  
  89. for(int i=0;i<n;i++){
  90. int c = i+1;
  91. for(int j=0;j<i+1;j++){
  92. v[j][i] = c;
  93. }
  94. }
  95. int sum = 0;
  96. for(int i=0;i<n;i++){
  97. for(int j=0;j<n;j++){
  98. sum+=v[i][j];
  99. }
  100. }
  101. cout << sum << " " << 2*n << endl;
  102. for(int i=n;i>=1;i--){
  103. cout << "1 " << i << " ";
  104. for(auto &it:k) cout << it << " ";
  105. cout << endl;
  106.  
  107. cout << "2 " << i << " ";
  108. for(auto &it:k) cout << it << " ";
  109. cout << endl;
  110. }
  111.  
  112. // debug(v);
  113. }
  114.  
  115.  
  116. signed main(){
  117. fastio();
  118.  
  119. int t=1; cin >> t;
  120. while(t--){
  121. solve();
  122. }
  123.  
  124. return 0;
  125. }
Success #stdin #stdout 0.01s 5296KB
stdin
Standard input is empty
stdout
0 0