#include<stdio.h>
#include<stdlib.h>
#include<string.h>
// for qsort
/*
int compare(int *t, int *s) {
return *t - *s;
}
*/
int check(int *data) {
int i, j;
int test;
for(i = 0; i < 4; ++i) {
test = 1;
for(j = 0; j < 4; ++j) {
if(!data[i*4+j]) {
test = 0;
break;
}
}
if(test) return 1;
}
for(i = 0; i < 4; ++i) {
test = 1;
for(j = 0; j < 4; ++j) {
if(!data[j*4+i]) {
test = 0;
break;
}
}
if(test) return 1;
}
test = 1;
for(i = 0; i < 4; ++i) {
if(!data[i*4+i]) {
test = 0;
break;
}
}
if(test) return 1;
for(i = 0; i < 4; ++i) {
test = 1;
if(!data[i*4+(3-i)]) {
test = 0;
break;
}
}
return test;
}
int main(void) {
int num;
int i, j, k;
char buf[6];
int X[4][4];
int O[4][4];
int emp;
int result;
for(i = 1; i <= num; ++i) {
emp = 0; result = 0;
for(j = 0; j < 4; ++j) {
for(k = 0; k < 4; ++k) {
if(buf[k] == 'X') {
X[j][k] = 1;
O[j][k] = 0;
} else if(buf[k] == 'O') {
X[j][k] = 0;
O[j][k] = 1;
} else if(buf[k] == 'T') {
X[j][k] = 1;
O[j][k] = 1;
} else {
X[j][k] = 0;
O[j][k] = 0;
emp = 1;
}
}
}
if(check((int*)X)) {
} else if(check((int*)O)) {
} else if(emp) {
printf("Game has not completed\n"); }
else {
}
}
return 0;
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8c3RkbGliLmg+CiNpbmNsdWRlPHN0cmluZy5oPgoKCi8vIGZvciBxc29ydAovKgppbnQgY29tcGFyZShpbnQgKnQsIGludCAqcykgewogICAgcmV0dXJuICp0IC0gKnM7Cn0KKi8KCmludCBjaGVjayhpbnQgKmRhdGEpIHsKICAgIGludCBpLCBqOwogICAgaW50IHRlc3Q7CiAgICBmb3IoaSA9IDA7IGkgPCA0OyArK2kpIHsKICAgICAgICB0ZXN0ID0gMTsKICAgICAgICBmb3IoaiA9IDA7IGogPCA0OyArK2opIHsKICAgICAgICAgICAgaWYoIWRhdGFbaSo0K2pdKSB7CiAgICAgICAgICAgICAgICB0ZXN0ID0gMDsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmKHRlc3QpIHJldHVybiAxOwogICAgfQogICAgZm9yKGkgPSAwOyBpIDwgNDsgKytpKSB7CiAgICAgICAgdGVzdCA9IDE7CiAgICAgICAgZm9yKGogPSAwOyBqIDwgNDsgKytqKSB7CiAgICAgICAgICAgIGlmKCFkYXRhW2oqNCtpXSkgewogICAgICAgICAgICAgICAgdGVzdCA9IDA7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZih0ZXN0KSByZXR1cm4gMTsKICAgIH0KCiAgICB0ZXN0ID0gMTsKICAgIGZvcihpID0gMDsgaSA8IDQ7ICsraSkgewogICAgICAgIGlmKCFkYXRhW2kqNCtpXSkgewogICAgICAgICAgICB0ZXN0ID0gMDsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgfQogICAgaWYodGVzdCkgcmV0dXJuIDE7CgogICAgZm9yKGkgPSAwOyBpIDwgNDsgKytpKSB7CiAgICAgICAgdGVzdCA9IDE7CiAgICAgICAgaWYoIWRhdGFbaSo0KygzLWkpXSkgewogICAgICAgICAgICB0ZXN0ID0gMDsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgfQoKICAgIHJldHVybiB0ZXN0Owp9CgoKaW50IG1haW4odm9pZCkgewogICAgaW50IG51bTsKICAgIGludCBpLCBqLCBrOwogICAgY2hhciBidWZbNl07CiAgICBpbnQgWFs0XVs0XTsKICAgIGludCBPWzRdWzRdOwogICAgaW50IGVtcDsKICAgIGludCByZXN1bHQ7CgogICAgc2NhbmYoIiVkIiwgJm51bSk7CiAgICBmb3IoaSA9IDE7IGkgPD0gbnVtOyArK2kpIHsKICAgICAgICBnZXRzKGJ1Zik7CiAgICAgICAgZW1wID0gMDsgcmVzdWx0ID0gMDsKICAgICAgICBmb3IoaiA9IDA7IGogPCA0OyArK2opIHsKICAgICAgICAgICAgZ2V0cyhidWYpOwogICAgICAgICAgICBmb3IoayA9IDA7IGsgPCA0OyArK2spIHsKICAgICAgICAgICAgICAgIGlmKGJ1ZltrXSA9PSAnWCcpIHsKICAgICAgICAgICAgICAgICAgICBYW2pdW2tdID0gMTsKICAgICAgICAgICAgICAgICAgICBPW2pdW2tdID0gMDsKICAgICAgICAgICAgICAgIH0gZWxzZSBpZihidWZba10gPT0gJ08nKSB7CiAgICAgICAgICAgICAgICAgICAgWFtqXVtrXSA9IDA7CiAgICAgICAgICAgICAgICAgICAgT1tqXVtrXSA9IDE7CiAgICAgICAgICAgICAgICB9IGVsc2UgaWYoYnVmW2tdID09ICdUJykgewogICAgICAgICAgICAgICAgICAgIFhbal1ba10gPSAxOwogICAgICAgICAgICAgICAgICAgIE9bal1ba10gPSAxOwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICBYW2pdW2tdID0gMDsKICAgICAgICAgICAgICAgICAgICBPW2pdW2tdID0gMDsKICAgICAgICAgICAgICAgICAgICBlbXAgPSAxOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBwcmludGYoIkNhc2UgIyVkOiAiLCBpKTsKICAgICAgICBpZihjaGVjaygoaW50KilYKSkgewogICAgICAgICAgICBwcmludGYoIlggd29uXG4iKTsKICAgICAgICB9IGVsc2UgaWYoY2hlY2soKGludCopTykpIHsKICAgICAgICAgICAgcHJpbnRmKCJPIHdvblxuIik7CiAgICAgICAgfSBlbHNlIGlmKGVtcCkgewogICAgICAgICAgICBwcmludGYoIkdhbWUgaGFzIG5vdCBjb21wbGV0ZWRcbiIpOwogICAgICAgIH0KICAgICAgICBlbHNlIHsKICAgICAgICAgICAgcHJpbnRmKCJEcmF3XG4iKTsKICAgICAgICB9CiAgICB9CgogICAgcmV0dXJuIDA7Cn0K