Engineer Artem
题意:a[i][j]可加1使得相邻元素不相等;
思路:(i+j) 分奇偶讨论。
#include<bits/stdc++.h>
#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int inf=2e18+100;
const int maxn=2e5+100;
int a[110][110];
int n,m;
signed main()
{
int tt;
cin>>tt;
while(tt--)
{
int n,m;
cin>>n>>m;
for(int i=1; i<=n; i++)
{
for(int j=1; j<=m; j++)
{
cin>>a[i][j];
if((i+j)%2&&a[i][j]%2==0)
{
a[i][j]++;
}
if((i+j)%2==0&&a[i][j]%2)
{
a[i][j]++;
}
}
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
cout<<a[i][j]<<" ";
}
cout<<"\n";
}
}
}