Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <list>
- #include <map>
- #include <set>
- #include <deque>
- #include <stack>
- #include <queue>
- #include <algorithm>
- #include <sstream>
- #include <iostream>
- #include <iomanip>
- #include <cstdio>
- #include <cmath>
- #include <cstdlib>
- #include <memory.h>
- #include <ctime>
- #include <bitset>
- using namespace std;
- #define ABS(a) ((a>0)?a:-(a))
- #define MIN(a,b) ((a<b)?(a):(b))
- #define MAX(a,b) ((a<b)?(b):(a))
- #define FOR(i,a,n) for (int i=(a);i<(n);++i)
- #define MEMS(a,b) memset((a),(b),sizeof(a))
- #define FI(i,n) for (int i=0; i<(n); ++i)
- #define pnt pair <int, int>
- #define mp make_pair
- #define LL long long
- #define U unsigned
- int dp[10][10][10][10][2];
- int dx1[]={2,2,1,1,-2,-2,-1,-1};
- int dy1[]={1,-1,2,-2,1,-1,2,-2};
- int dx2[]={-1,-1};
- int dy2[]={1,-1};
- bool isValid(int x, int y) {
- return ((x>=0) && (x<8) && (y>=0) && (y<8));
- }
- int r(int x1, int y1, int x2, int y2, int f) {
- if (dp[x1][y1][x2][y2][f] != -1)
- return dp[x1][y1][x2][y2][f];
- if (f == 0) {
- FOR(k,0,8) {
- int nx = x1+dx1[k];
- int ny = y1+dy1[k];
- if (!isValid(nx,ny))
- continue;
- if ((nx == x2) && (ny == y2))
- return dp[x1][y1][x2][y2][f] = 0;
- if (r(nx,ny,x2,y2,1) == 0) {
- return dp[x1][y1][x2][y2][f] = 0;
- }
- }
- return dp[x1][y1][x2][y2][f] = 1;
- }
- else {
- FOR(k,0,2) {
- int nx = x2 + dx2[k];
- int ny = y2 + dy2[k];
- if (!isValid(nx,ny))
- continue;
- if ((nx == x1) && (ny == y1)) {
- if ((x1 == 0) || (x1 == 7) || (y1 == 0) || (y1 == 7))
- continue;
- return dp[x1][y1][x2][y2][f] = 1;
- }
- if (nx == 0)
- return dp[x1][y1][x2][y2][f] = 1;
- if (r(x1,y1,nx,ny,0) == 1) {
- return dp[x1][y1][x2][y2][f] = 1;
- }
- }
- return dp[x1][y1][x2][y2][f] = 0;
- }
- }
- string s1,s2,s3;
- int main()
- {
- #ifdef Fcdkbear
- freopen("in.txt", "r", stdin);
- //freopen("out.txt", "w", stdout);
- double beg = clock();
- #endif
- MEMS(dp,-1);
- cin>>s1>>s2>>s3;
- int f = r(s2[1] - '1', s2[0] - 'a', s3[1] - '1', s3[0] - 'a', s1[0] == 'b');
- if (f)
- cout<<"Black"<<endl;
- else
- cout<<"White"<<endl;
- #ifdef Fcdkbear
- double end = clock();
- fprintf(stderr, "*** Total time = %.3lf ***\n", (end - beg) / CLOCKS_PER_SEC);
- #endif
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement