Codeforces Round #254 (Div. 2) 445A. DZY Loves Chessboard Solution
Solution in C++:
/// La ilaha illellahu muhammadur rasulullah
///******Bismillahir-Rahmanir-Rahim******///
/// Abul Hasnat Tonmoy
/// Department of CSE,23rd batch
/// Islamic University,Bangladesh
///**********ALLAH IS ALMIGHTY************///
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int r,c,i,j;
- cin>>r>>c;
- char mt[101][101];
- for(i=1; i<=r; i++)
- {
- for(j=1; j<=c; j++)
- {
- cin>>mt[i][j];
- }
- }
- for(i=1; i<=r; i++)
- {
- for(j=1; j<=c; j++)
- {
- if(i%2==1&&j%2==1&&mt[i][j]=='.')cout<<"B";
- else if(i%2==1&&j%2==0&&mt[i][j]=='.')cout<<"W";
- else if(i%2==0&&j%2==1&&mt[i][j]=='.')cout<<"W";
- else if(i%2==0&&j%2==0&&mt[i][j]=='.')cout<<"B";
- else cout<<"-";
- }
- cout<<endl;
- }
- }
No comments