#include<stdio.h>
#include<stdbool.h>
bool valid(int n){
if(n >= 0 && n < 2)return true;
return false;
}
void print(int b[2][2]){
for(int i = 0; i < 2; i++){
for(int j = 0; j < 2; j++){
}
}
}
void mine(int a[2][2], int b[2][2], int x, int y, int sum){
b[x][y] = 0;
if(valid(x + 1))mine(a, b, x + 1, y, sum);
else if(valid(y + 1))mine(a, b, 0, y + 1, sum);
else print
(b
);print
(a
);printf("\n");
b[x][y] = 1;
int temp[2][2], sum2 = sum;
for(int i = 0; i < 2; i++){
for(int j = 0; j < 2; j++){
temp[i][j] = a[i][j];
}
}
for(int i = -1; i < 2; i++){
for(int j = -1; j < 2; j++){
if(valid(x + i) && valid(y + j))temp[(x + i)][(y + j)]--;
sum2 --;
}
}
if(valid(x + 1))mine(temp, b, x + 1, y, sum2);
else if(valid(y + 1))mine(temp, b, 0, y + 1, sum2);
else print
(b
);print
(temp
);printf("\n"); }
int main(){
int a[2][2], b[2][2], sum = 0;
for(int i = 0; i < 2; i++){
for(int j = 0; j < 2; j++){
sum += a[i][j];
}
}
mine(a, b, 0, 0, sum);
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8c3RkYm9vbC5oPgoKYm9vbCB2YWxpZChpbnQgbil7CiAgICBpZihuID49IDAgJiYgbiA8IDIpcmV0dXJuIHRydWU7CiAgICByZXR1cm4gZmFsc2U7Cn0KCnZvaWQgcHJpbnQoaW50IGJbMl1bMl0pewogICAgZm9yKGludCBpID0gMDsgaSA8IDI7IGkrKyl7CiAgICAgICAgZm9yKGludCBqID0gMDsgaiA8IDI7IGorKyl7CiAgICAgICAgICAgIHByaW50ZigiJWQgIiwgYltpXVtqXSk7CiAgICAgICAgfQogICAgICAgIHByaW50ZigiXG4iKTsKICAgIH0KfQoKdm9pZCBtaW5lKGludCBhWzJdWzJdLCBpbnQgYlsyXVsyXSwgaW50IHgsIGludCB5LCBpbnQgc3VtKXsKICAgIGJbeF1beV0gPSAwOwogICAgaWYodmFsaWQoeCArIDEpKW1pbmUoYSwgYiwgeCArIDEsIHksIHN1bSk7CiAgICBlbHNlIGlmKHZhbGlkKHkgKyAxKSltaW5lKGEsIGIsIDAsIHkgKyAxLCBzdW0pOwogICAgZWxzZSBwcmludChiKTtwcmludChhKTtwcmludGYoIlxuIik7CgogICAgYlt4XVt5XSA9IDE7CiAgICBpbnQgdGVtcFsyXVsyXSwgc3VtMiA9IHN1bTsKICAgIGZvcihpbnQgaSA9IDA7IGkgPCAyOyBpKyspewogICAgICAgIGZvcihpbnQgaiA9IDA7IGogPCAyOyBqKyspewogICAgICAgICAgICB0ZW1wW2ldW2pdID0gYVtpXVtqXTsKICAgICAgICB9CiAgICB9CgogICAgZm9yKGludCBpID0gLTE7IGkgPCAyOyBpKyspewogICAgICAgIGZvcihpbnQgaiA9IC0xOyBqIDwgMjsgaisrKXsKICAgICAgICAgICAgaWYodmFsaWQoeCArIGkpICYmIHZhbGlkKHkgKyBqKSl0ZW1wWyh4ICsgaSldWyh5ICsgaildLS07CiAgICAgICAgICAgIHN1bTIgLS07CiAgICAgICAgfQogICAgfQogICAgaWYodmFsaWQoeCArIDEpKW1pbmUodGVtcCwgYiwgeCArIDEsIHksIHN1bTIpOwogICAgZWxzZSBpZih2YWxpZCh5ICsgMSkpbWluZSh0ZW1wLCBiLCAwLCB5ICsgMSwgc3VtMik7CiAgICBlbHNlIHByaW50KGIpO3ByaW50KHRlbXApO3ByaW50ZigiXG4iKTsKfQoKaW50IG1haW4oKXsKICAgIGludCBhWzJdWzJdLCBiWzJdWzJdLCBzdW0gPSAwOwogICAgZm9yKGludCBpID0gMDsgaSA8IDI7IGkrKyl7CiAgICAgICAgZm9yKGludCBqID0gMDsgaiA8IDI7IGorKyl7CiAgICAgICAgICAgIHNjYW5mKCIlZCIsICZhW2ldW2pdKTsKICAgICAgICAgICAgc3VtICs9IGFbaV1bal07CiAgICAgICAgfQogICAgfQogICAgbWluZShhLCBiLCAwLCAwLCBzdW0pOwp9