Problem - C - Codeforces
构造n * m 的矩阵,每次选左上4个格子的 异或结果 和 右下4个格子的异或结果 都一样
#include <iostream>
#include <bits/stdc++.h>
#include <cstring>
#include <vector>
#include <algorithm>
#define x first
#define y second
#define fu(i,a,b) for(int i=a;i<=b;i ++ )
#define fd(i,a,b) for(int i=a;i>=b;i -- )
#define endl '\n'
#define ms(x,y) memset(x,y,sizeof x)
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef pair<double,int> PDI;
typedef pair<char,int> PCI;
typedef pair<string,int> PSI;
typedef pair<int,string> PIS;
typedef pair<LL,LL> PLL;
//typedef __int128 i128;
typedef unsigned long long ULL;
const int N = 1e5+ 10,M = 1e5 + 10,INF = 0x3f3f3f3f ;
const int mod = 1e9;
const double eps = 1e-8;
int n,m,ans[210][210];
vector<int> r,c;
inline void solve()
{
cin >> n>> m;
cout << n * m << endl;
fu(i,0,n-1)
fu(j,0,m-1)
{
cout << (i<< 10) + j << " \n"[j == m-1];
}
}
signed main()
{
// freopen("1.txt","w",stdout);
ios
int t=1;
cin>>t;
int now = 1;
while(t -- )
{
// cout<<"Case ";
// cout<<"Case #";
// cout<< now ++ <<": ";
solve();
}
return 0;
}