acm-(思維、奇偶性、矩陣)Codeforces Round #682 (Div. 2) C. Engineer Artem
傳送門
要讓所有相鄰數兩兩不同,不妨考慮讓相鄰格子奇偶性不同,也就是對於
a
i
,
j
a_{i,j}
ai,j而言當
i
+
j
i+j
i+j為奇數的時候那麼我們讓
a
i
,
j
a_{i,j}
ai,j為奇數,當
i
+
j
i+j
i+j為偶數的時候我們讓
a
i
,
j
a_{i,j}
ai,j為偶數。題目給出的
+
1
+1
+1操作實際上就是改變奇偶性的操作,也就是我們能夠控制
a
i
,
j
a_{i,j}
ai,j的奇偶性,因此本題也就得到了解決。
int main(){
int t=rd();
while(t--){
int n=rd(),m=rd();
FOR(i,0,n){
FOR(j,0,m){
int u=rd();
if((u^i^j)&1){
u++;
}
wr(u),putchar(' ');
}
puts("");
}
}
}
相關文章
- Codeforces Round #682 (Div. 2)
- Codeforces Round #688 (Div. 2) C. Triangles(思維,數學)
- C. Lose it!(思維)Codeforces Round #565 (Div. 3)
- C. Dominant Piranha(思維) Codeforces Round #677 (Div. 3)NaN
- Codeforces C. Colored Rooks 構造 (Codeforces Round #518 (Div. 2) )
- Codeforces Round #646 (Div. 2)【C. Game On Leaves 題解】GAM
- 【CodeForces】 Codeforces Round #672 (Div. 2) B.Rock and Lever (思維&位運算)
- Educational Codeforces Round 165 (Rated for Div. 2) C. Minimizing the Sum題解
- Codeforces Round #541 (Div. 2)
- Codeforces Round 940 (Div. 2)
- Codeforces Round 934 (Div. 2)
- Codeforces Round 932 (Div. 2)
- Codeforces Round 948 (Div. 2)
- Codeforces Round #639 (Div. 2)
- Codeforces Round #672 (Div. 2)
- Codeforces Round #678 (Div. 2)
- Codeforces Round #673 (Div. 2)
- Codeforces Round 987 (Div. 2)
- Codeforces Round 976 (Div. 2)
- Codeforces Round 975 (Div. 2)
- Codeforces Round 986 (Div. 2)
- Codeforces Round 973 (Div. 2)
- Codeforces Round 969 (Div. 2)
- Codeforces Round 873 (Div. 2)
- Codeforces Round 967 (Div. 2)
- Codeforces Round 965 (Div. 2)
- Codeforces Round 963 (Div. 2)
- Codeforces Round 979 (Div. 2)
- Codeforces Round 972 (Div. 2)
- Codeforces Round 949 (Div. 2)
- Codeforces Round 955 (Div. 2)
- Codeforces Round 951 (Div. 2)
- Codeforces Round 961 (Div. 2)
- Codeforces Round 958 (Div. 2)
- Codeforces Round 960 (Div. 2)
- Codeforces Round 953 (Div. 2)
- Codeforces Round 982 (Div. 2)
- Codeforces Round 945 (Div. 2)