Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define mem(x,y) memset(x,y,sizeof(x))
- #define PI acos(-1.00)
- #define ERR 1e-9
- #define __ ios_base::sync_with_stdio(0); cin.tie(0);
- #define file freopen("input.txt", "rt", stdin);freopen("output.txt", "wt", stdout);
- const int inf=0x7FFFFFFF ;
- typedef long long ll;
- ll _GCD(ll a,ll b){return b?_GCD(b,a%b):a;}//gcd
- //prototypes
- ll solution();
- ll N;
- ll mark[105][105];
- ll xx[]={-2,-2,2,2,-1,-1,1,1};
- ll yy[]={1,-1,1,-1,2,-2,2,-2};
- void DFS(ll i,ll j,ll col)
- {
- if(i<1||i>N||j<1||j>N)
- return;
- if(mark[i][j]!=-1)
- return ;
- mark[i][j]=col;
- for(ll k=0;k<8;k++)
- {
- DFS(i+xx[k],j+yy[k],!col);
- }
- }
- int main()
- {
- //__;
- //file;
- int tc=1,cas=0;
- //cin>>tc;
- while(tc--)
- {
- //printf("Case %d: ",++cas);
- solution();
- }
- return 0;
- }
- ll solution()
- {
- cin>>N;
- mem(mark,-1);
- ll col=1;
- for(ll i=1;i<=N;i++)
- {
- for(ll j=1;j<=N;j++)
- {
- if(mark[i][j]==-1){
- DFS(i,j,col);
- col=!col;
- }
- }
- }
- char s[]={'W','B'};
- for(ll i=1;i<=N;i++)
- {
- for(ll j=1;j<=N;j++)
- {
- cout<<s[mark[i][j]];
- }
- cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement