#include #include #include #include using namespace std; struct COORD { int x; int y; }; int main ( void ) { int white_chessboard [8][8]; int black_chessboard [8][8]; array, 8>, 8> data; bool visited_chessboard [8][8]; pair white; pair black; int x, y; cin >> x >> y; white = make_pair(x - 1, y - 1); cin >> x >> y; black = make_pair(x - 1, y - 1); for(int i = 0; i < 8; ++i) { for(int k = 0; k < 8; ++k) { COORD tmp; tmp.x = i+2; tmp.y = k+1; if(tmp.x < 8 && tmp.y < 8) { data[i][k].push_back(tmp); } tmp.x = i+2; tmp.y = k-1; if(tmp.x < 8 && tmp.y >= 0) { data[i][k].push_back(tmp); } tmp.x = i-2; tmp.y = k+1; if(tmp.x >= 0 && tmp.y < 8) { data[i][k].push_back(tmp); } tmp.x = i-2; tmp.y = k-1; if(tmp.x >= 0 && tmp.y >= 0 ) { data[i][k].push_back(tmp); } //------- tmp.x = i+1; tmp.y = k+2; if(tmp.x < 8 && tmp.y < 8) { data[i][k].push_back(tmp); } tmp.x = i+1; tmp.y = k-2; if(tmp.x < 8 && tmp.y >= 0 ) { data[i][k].push_back(tmp); } tmp.x = i-1; tmp.y = k+2; if(tmp.x >= 0 && tmp.y < 8) { data[i][k].push_back(tmp); } tmp.x = i-1; tmp.y = k-2; if(tmp.x >= 0 && tmp.y >= 0 ) { data[i][k].push_back(tmp); } } } deque> queue; queue.push_back(white); white_chessboard[white.first][white.second] = 0; for ( int i = 0; i < 8; ++i ) { for ( int j = 0; j < 8; ++j ) visited_chessboard[i][j] = false; } visited_chessboard[white.first][white.second] = true; while ( !queue.empty() ) { pair current = queue.front(); queue.pop_front(); for ( auto i = data[current.first][current.second].begin(); i != data[current.first][current.second].end(); ++i ) { if ( !visited_chessboard[i -> x][i -> y] ) { white_chessboard[i -> x][i -> y] = white_chessboard[current.first][current.second] + 1; queue.push_back(make_pair(i -> x, i -> y)); visited_chessboard[i -> x][i -> y] = true; } } } /* cout << "White: " << endl; for ( int i = 0; i < 8; ++i ) { for ( int j = 0; j < 8; ++j ) cout << white_chessboard[i][j] << " "; cout << endl; } */ queue.push_back(black); black_chessboard[black.first][black.second] = 0; for ( int i = 0; i < 8; ++i ) { for ( int j = 0; j < 8; ++j ) visited_chessboard[i][j] = false; } visited_chessboard[black.first][black.second] = true; while ( !queue.empty() ) { pair current = queue.front(); queue.pop_front(); for ( auto i = data[current.first][current.second].begin(); i != data[current.first][current.second].end(); ++i ) { if ( !visited_chessboard[i -> x][i -> y] ) { black_chessboard[i -> x][i -> y] = black_chessboard[current.first][current.second] + 1; queue.push_back(make_pair(i -> x, i -> y)); visited_chessboard[i -> x][i -> y] = true; } } } /* cout << "Black: " << endl; for ( int i = 0; i < 8; ++i ) { for ( int j = 0; j < 8; ++j ) cout << black_chessboard[i][j] << " "; cout << endl; } */ int white_wins = 0; int black_wins = 0; for ( int i = 0; i < 8; ++i ) { for ( int j = 0; j < 8; ++j ) { if ( white_chessboard[i][j] == black_chessboard[i][j] ) ++black_wins; else if ( white_chessboard[i][j] == black_chessboard[i][j] + 1) ++white_wins; } } // cout << "Black: " << black_wins << endl; // cout << "White: " << white_wins << endl; if ( black_wins == white_wins ) cout << "draw"; else if ( black_wins < white_wins ) cout << "white"; else cout << "black"; cout << endl; }