// queens.cpp : Defines the entry point for the console application. // #include #include #include #include #define MAXN 200 #define MAXK 1000 #define MAXR 200 #define MAXC 8 int n, r, k; int arr[MAXN][MAXN]; int xq[8]; int yq[8]; int countq = 0; int bestx = 0; int besty = 0; int tempk = 0; int bestpoints = 0; int border = 0; void init_result(){ if (n >= 5) { countq = 5; xq[0] = 0; yq[0] = 1; xq[1] = 1; yq[1] = 4; xq[2] = 2; yq[2] = 2; xq[3] = 3; yq[3] = 0; xq[4] = 4; yq[4] = 3; border = 5; if (n > 5) { for (int i = 0; i < countq; i++) { xq[i] = xq[i] + 1; yq[i] = yq[i] + 1; } xq[countq] = 0; yq[countq] = 2; countq++; tempk++; border++; if (tempk != k) { xq[countq] = 4; yq[countq] = 0; countq++; tempk++; } if (tempk != k) { if (n > 6) { xq[countq] = 6; yq[countq] = 4; countq++; tempk++; border++; } else if (k - tempk >= 2) { xq[countq] = 5; yq[countq] = 3; countq++; tempk++; } } } } else { switch (n) { case 1: countq = 1; xq[0] = 0; yq[0] = 0; break; case 2: countq = 2; xq[0] = 0; yq[0] = 0; xq[1] = 1; yq[1] = 1; break; case 3: countq = 3; xq[0] = 0; yq[0] = 0; xq[1] = 1; yq[1] = 2; xq[2] = 2; yq[2] = 0; if (r > 1) { tempk++; } if (k - tempk >= 3) { xq[countq] = 1; yq[countq] = 1; countq++; tempk++; tempk++; tempk++; } if (k - tempk >= 3) { xq[countq] = 0; yq[countq] = 1; countq++; tempk++; tempk++; tempk++; } break; case 4: countq = 3; xq[0] = 0; yq[0] = 0; xq[1] = 1; yq[1] = 2; xq[2] = 3; yq[2] = 1; if (r = 1) { xq[countq] = 3; yq[countq] = 3; countq++; xq[countq] = 0; yq[countq] = 3; countq++; tempk++; } if (r = 2) { xq[countq] = 0; yq[countq] = 3; countq++; tempk++; if (k - tempk >= 1) { xq[countq] = 3; yq[countq] = 3; countq++; tempk++; } if (k - tempk >= 2) { xq[countq] = 3; yq[countq] = 0; countq++; tempk++; tempk++; } } if (r = 3) { xq[countq] = 2; yq[countq] = 3; countq++; tempk++; if (k - tempk >= 2) { xq[countq] = 0; yq[countq] = 2; countq++; tempk++; tempk++; } } break; } } } void print_result(){ for (int i = 0; i < countq; i++) { if (i != 0) { printf("\n"); } printf("%d %d", xq[i] + bestx + 1, yq[i] + besty + 1); } } int main(int argc, char * argv[]) { freopen("queens.in", "r", stdin); freopen("queens.out", "w", stdout); scanf("%d %d %d", &n, &r, &k); for (int i = 0; i < n; i++) { scanf("\n"); for (int j = 0; j < n; j++) { if (j == (n - 1)) { scanf("%d", &arr[i][j]); } else { scanf("%d ", &arr[i][j]); } } } init_result(); if (n > 5) { if (n - border >= 2) { for (int i = 0; i < countq; i++) { xq[i] = xq[i] + n - border - 1; yq[i] = yq[i] + n - border - 1; } //bestx = n - border - 1; //besty = n - border - 1; } } print_result(); }