#include #include #include #include #include #include #include using namespace std; #define DEBUG //comment this line to pull out print statements #ifdef DEBUG #define TAB '\t' #define debug(a, end) cout << #a << ": " << a << end #define dbg(end) end #else #define debug(a, end) #define dbg(end) #endif typedef pair point; typedef vector vi; typedef vector vp; #define UN(v) SORT(v),v.erase(unique(v.begin(),v.end()),v.end()) #define SORT(c) sort((c).begin(),(c).end()) #define FOR(i,a,b) for (int i=(a); i < (b); i++) #define REP(i,n) FOR(i,0,(int)n) #define CL(a,b) memset(a,b,sizeof(a)) #define CL2d(a,b,x,y) memset(a, b, sizeof(a[0][0])*x*y) /*global variables*/ char board[9][9]; const int offset = 2; /*global variables*/ void dump() { //dump data } bool getInput() { //get input REP(i, 5) { REP(j, 5) { scanf("%c", &board[offset+i][offset+j]); } scanf(" "); } return true; } bool check_knight(int row, int col) { return ( //top left (board[row+offset-2][col+offset-1] == '.') && //top right (board[row+offset-2][col+offset+1] == '.') && //left up (board[row+offset-1][col+offset-2] == '.') && //left down (board[row+offset+1][col+offset-2] == '.') && //bot left (board[row+offset+2][col+offset-1] == '.') && //bot right (board[row+offset+2][col+offset+1] == '.') && //right up (board[row+offset-1][col+offset+2] == '.') && //right down (board[row+offset+1][col+offset+2] == '.')); } void process() { //process input bool v = true; //count knights as well. int nk = 0; REP(i, 5) { REP(j, 5) { if (board[offset+i][offset+j] == 'k') { if (v) v = check_knight(i, j); nk++; } } } printf("%svalid\n", nk == 9 ? (v ? "" : "in") : "in"); } int main() { /*CLEAR GLOBAL VARIABLES!*/ CL2d(board, '.', 9, 9); /*CLEAR GLOBAL VARIABLES!*/ getInput(); process(); return 0; }