In Back and Forth problem (Bronze 2018), my code outputs the correct answer when I run it with the test cases (i downloaded the test cases with its corresponding answer). However, when I submit it in the USACO website, it does not give the correct result. I checked it multiple times but my code is the same for both.
int arr[20], barr[20];
bool bool_arr[20], bool_barr[20];
set answer;
for (int i = 0; i < 10; i++) {
cin >> arr[i];
barr[i] = arr[i];
bool_arr[i] = true;
}
for (int i = 10; i < 20; i++) {
cin >> barr[i];
arr[i] = barr[i];
bool_barr[i] = true;
}
for (int i = 0; i < 20; i++) {
if (bool_arr[i]) {
bool_arr[i] = false;
bool_barr[i] = true;
for (int j = 0; j < 20; j++) {
if (bool_barr[j]) {
bool_barr[j] = false;
bool_arr[j] = true;
for (int k = 0; k < 20; k++) {
if (bool_arr[k]) {
bool_arr[k] = false;
bool_barr[k] = true;
for (int l = 0; l < 20; l++) {
if (bool_barr[l]) {
bool_barr[l] = false;
bool_arr[l] = true;
int total = 1000;
for (int m = 0; m < 10; m++) {
if (!bool_arr[m]) {
total -= arr[m];
}
}
for (int m = 10; m < 20; m++) {
if (bool_arr[m]) {
total += arr[m];
}
}
answer.insert(total);
bool_barr[l] = true;
bool_arr[l] = false;
}
}
bool_arr[k] = true;
bool_barr[k] = false;
}
}
bool_barr[j] = true;
bool_arr[j] = false;
}
}
bool_arr[i] = true;
bool_barr[i] = false;
}
}
cout << answer.size();
return 0;