-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA_Diverse_Game.cpp
63 lines (63 loc) · 1.55 KB
/
A_Diverse_Game.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using namespace chrono;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define debug(x...) { cout << "(" << #x << ")" << " = ( "; PRINT(x); }
template <typename T1> void PRINT(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void PRINT(T1 t1, T2... t2) { cout << t1 << " , "; PRINT(t2...); }
#define all(v) (v).begin(), (v).end()
//(data type to be stored (pair,int,string,vector),"null_type"(specifically used for set),comparator,underlying tree,class denoting the policy for updating node invaraints)
typedef tree < pair<int,int>, null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update > pbds;
void solve();
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.setf(ios::fixed);
cout.precision(10);
int t;
cin >> t;
while (t--)
{
solve();
}
}
void solve()
{
int n,m;
cin>>n>>m;
int a[n][m];
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cin>>a[i][j];
}
}
int count=n*m;
if(count==1)
{
cout<<-1<<endl;
return;
}
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
int x=a[i][j]+1;
if(x>count)
x=1;
a[i][j]=x;
}
}
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
cout<<a[i][j]<<" ";
cout<<endl;
}
}