Codeforces Round #254 (Div. 2) 445A. DZY Loves Chessboard Solution


  Problem Link  :   https://codeforces.com/problemset/problem/445/A
 

 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************///
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int r,c,i,j;
  6. cin>>r>>c;
  7. char mt[101][101];
  8. for(i=1; i<=r; i++)
  9. {
  10. for(j=1; j<=c; j++)
  11. {
  12. cin>>mt[i][j];
  13. }
  14. }
  15. for(i=1; i<=r; i++)
  16. {
  17. for(j=1; j<=c; j++)
  18. {
  19. if(i%2==1&&j%2==1&&mt[i][j]=='.')cout<<"B";
  20. else if(i%2==1&&j%2==0&&mt[i][j]=='.')cout<<"W";
  21. else if(i%2==0&&j%2==1&&mt[i][j]=='.')cout<<"W";
  22. else if(i%2==0&&j%2==0&&mt[i][j]=='.')cout<<"B";
  23. else cout<<"-";
  24. }
  25. cout<<endl;
  26. }
  27. }

No comments

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h &g...

Powered by Blogger.