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)
- C. Lose it!(思維)Codeforces Round #565 (Div. 3)
- Codeforces Round #688 (Div. 2) C. Triangles(思維,數學)
- Codeforces Round #213 (Div. 2)(矩陣)矩陣
- C. Dominant Piranha(思維) Codeforces Round #677 (Div. 3)NaN
- Codeforces Round #446 (Div. 2) C. PrideIDE
- Codeforces Round #242 (Div. 2) C. Magic FormulasORM
- Codeforces Round #215 (Div. 2) C. Sereja and AlgorithmGo
- Codeforces Round #243 (Div. 2) C. Sereja and Swaps
- Codeforces Round #646 (Div. 2)【C. Game On Leaves 題解】GAM
- Codeforces Round #251 (Div. 2) C. Devu and Partitioning of the Arraydev
- Codeforces Round #225 (Div. 2)(B思維題,E:dfs+樹狀陣列)陣列
- 【CodeForces】 Codeforces Round #672 (Div. 2) B.Rock and Lever (思維&位運算)
- Codeforces C. Colored Rooks 構造 (Codeforces Round #518 (Div. 2) )
- Codeforces Beta Round #6 (Div. 2 Only) C. Alice, Bob and Chocolate 水題
- Codeforces Round #228 (Div. 1) C. Fox and Card GameGAM
- Codeforces Round #371 (Div. 2) C. Sonya and Queries[Map|二進位制]
- Codeforces Round #639 (Div. 2)
- Codeforces Round #541 (Div. 2)
- Codeforces Round #678 (Div. 2)
- Codeforces Round #747 (Div. 2)
- Codeforces Round #673 (Div. 2)
- Codeforces Round #672 (Div. 2)
- Codeforces Round #448 (Div. 2) A
- Codeforces Round #217 (Div. 2)
- Codeforces Round #256 (Div. 2)
- Codeforces Round #259 (Div. 2)
- Codeforces Round #257 (Div. 2)
- Codeforces Round #258 (Div. 2)
- Codeforces Round #171 (Div. 2)
- Codeforces Round #173 (Div. 2)
- Codeforces Round 951 (Div. 2)
- Codeforces Round 955 (Div. 2)
- Codeforces Round 953 (Div. 2)
- Codeforces Round 975 (Div. 2)
- Codeforces Round 976 (Div. 2)
- Codeforces Round 972 (Div. 2)
- Codeforces Round 979 (Div. 2)