#include "bits/stdc++.h" using namespace std; int board[27][27]; int arah[2] = {1, -1}; int n; void bfs(int a, int b){ queue > que; que.push(make_pair(0, 0)); int count = 0; int x, y; while(!que.empty()){ x = que.front().first; y = que.front().second; //printf("at %d, %d\n", x, y); que.pop(); for (int z=0; z<2; z++){ for(int i=0; i<2; i++){ for(int j=0; j<2; j++){ if (x + (a*arah[i]) >= 0 && x + (a*arah[i]) < n && y + (b*arah[j]) >= 0 && y + (b*arah[j]) < n){ //printf("Arah: + (%d, %d)\n", (a*arah[i]), (b*arah[j])); if (!board[x+(a*arah[i])][y+(b*arah[j])]){ que.push(make_pair(x+(a*arah[i]), y+(b*arah[j]))); board[x+(a*arah[i])][y+(b*arah[j])] += (board[x][y] + 1); //printf("%d, %d added to queue\n", x+(a*arah[i]), y+(b*arah[j])); } } } } swap(a, b); } } } void resetBoard(){ for(int i=0; i