Here is my code for the eight queens problem. I checked it with many test case and it's correct. But when I submitted it to https://open.kattis.com/, it noticed me that my code is the wrong answer. So, where is my code fails? Please help!
public class Chesss {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
// TODO code application logic here
int[] row = new int[8];
int[] column = new int[8];
int[] lcros= new int[15];
int[] rcros = new int[15];
for (int i = 0; i < 8; i ++) {
row[i] = 0;
column[i] = 0;
}
for (int i = 0; i < 15; i ++) {
lcros[i] = 0;
rcros[i] = 0;
}
boolean check = true;
for (int i = 0; i < 8; i ++) {
for (int j = 0; j < 8; j ++) {
char in = (char)System.in.read();
if (in == '\n') {
in = (char)System.in.read();
}
if (in == '*') {
if (row[i] == 1) {
check = false;
} else {
row[i] = 1;
}
if (column[j] == 1) {
check = false;
} else {
column[j] = 1;
}
if (lcros[i + j] == 1) {
check = false;
} else {
lcros[i + j] = 1;
}
if (rcros[i - j + 7] == 1) {
check = false;
} else {
rcros[i - j + 7] = 1;
}
}
}
}
if (check == true) {
System.out.print("valid");
} else System.out.print("invalid");
}
}