-
Notifications
You must be signed in to change notification settings - Fork 1
/
c.cpp
56 lines (44 loc) · 1.09 KB
/
c.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
#include <iostream>
#include <cassert>
using namespace std;
const int N = 105;
int n, m, a[N][N];
void readInput() {
scanf("%d %d ", &n, &m);
for(int i = 0;i < n;i++) {
for(int j = 0;j < m;j++)
scanf("%d ", &a[i][j]);
}
}
void solve() {
bool startOdd = true;
for(int i = 0;i < n;i++) {
for(int j = 0;j < m;j++) {
int currVal;
if(startOdd) {
if((j & 1) == 0)
currVal = ((a[i][j] & 1) == 1 ? a[i][j] : a[i][j] + 1);
else
currVal = ((a[i][j] & 1) == 1 ? a[i][j] + 1 : a[i][j]);
}
else {
if((j & 1) == 0)
currVal = ((a[i][j] & 1) == 1 ? a[i][j] + 1 : a[i][j]);
else
currVal = ((a[i][j] & 1) == 1 ? a[i][j] : a[i][j] + 1);
}
printf("%d ", currVal);
}
startOdd = !startOdd;
printf("\n");
}
}
int main() {
int t;
scanf("%d ", &t);
while(t --) {
readInput();
solve();
}
return 0;
}