Codeforces Round #254 (Div. 2), problem: (A) DZY Loves Chessboard editorial: not shared yet (at the time publishing this post)
Codeforces Round #254 (Div. 2), problem: (A) DZY Loves Chessboard solution: http://ideone.com/HiBH3H
#include <iostream> #include <cstdio> #include <vector> using namespace std; int main() { int n, m; char s[105][105]; vector <string> v; scanf("%d%d", &n, &m); for(int i=0; i<n; i++) scanf("%s", s[i]); for(int i=0; i<n; i++) { string d=""; for(int j=0; j<m; j++) { if(s[i][j]=='.' && j%2==0 && i%2==0) d+='B'; else if(s[i][j]=='.' && j%2==0 && i%2==1) d+='W'; else if(s[i][j]=='.' && j%2==1 && i%2==0) d+='W'; else if(s[i][j]=='.' && j%2==1 && i%2==1) d+='B'; else d+='-'; } v.push_back(d); } for(vector <string>::iterator i=v.begin(); i!=v.end(); i++) cout<<*i<<endl; return 0; }
No comments:
Post a Comment