Witam, dostaję błąd NZEC przy próbie wysłania tego kodu:
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int howMuchTimes = sc.nextInt();
while (howMuchTimes > 0) {
Scanner sc1 = new Scanner(System.in);
String testBlackValues = sc1.nextLine();
String testGreyValues = sc1.nextLine();
String[] allBlackScannedNumbersList = testBlackValues.split(" ");
String[] allGreyScannedNumbersList = testGreyValues.split(" ");
List<Coordinates> scannedBlackCoordinatesList = convertListFromStringsToCoordinates(allBlackScannedNumbersList);
List<Coordinates> scannedGreyCoordinatesList = convertListFromStringsToCoordinates(allGreyScannedNumbersList);
List<Integer> listOfResultsFromParenthesesBlack = getListOfResultsFromParentheses(scannedBlackCoordinatesList);
List<Integer> listOfResultsFromParenthesesGrey = getListOfResultsFromParentheses(scannedGreyCoordinatesList);
scannedBlackCoordinatesList = addParenthesesResultToEachCoordinate(scannedBlackCoordinatesList, listOfResultsFromParenthesesBlack);
scannedGreyCoordinatesList = addParenthesesResultToEachCoordinate(scannedGreyCoordinatesList, listOfResultsFromParenthesesGrey);
float resultOfGaussMethodBlack = getResultOfGaussMethod(scannedBlackCoordinatesList);
float resultOfGaussMethodGrey = getResultOfGaussMethod(scannedGreyCoordinatesList);
int result = (int) ((resultOfGaussMethodGrey - resultOfGaussMethodBlack) * 6 + resultOfGaussMethodBlack * 10);
System.out.println(result);
howMuchTimes--;
}
}
public static List<Coordinates> convertListFromStringsToCoordinates(String[] stringList) {
List<Coordinates> scannedCoordinatesList = new ArrayList<>();
int x = 0;
int y = 0;
for (int i = 0; i < (stringList.length - 1); i++) {
if (i % 2 == 0) {
x = Integer.parseInt(stringList[i]);
} else {
y = Integer.parseInt(stringList[i]);
scannedCoordinatesList.add(new Coordinates(x, y));
}
}
return scannedCoordinatesList;
}
// Return (Xi+1 – Xi-1)
public static List<Integer> getListOfResultsFromParentheses(List<Coordinates> numberArray) {
List<Integer> resultList = new ArrayList<>();
resultList.add(numberArray.get(1).X - numberArray.get(numberArray.size() - 1).X);
for (int i = 1; i < numberArray.size() - 1; i++) {
resultList.add(numberArray.get(i + 1).X - numberArray.get(i - 1).X);
}
resultList.add(numberArray.get(0).X - numberArray.get(numberArray.size() - 2).X);
return resultList;
}
public static List<Coordinates> addParenthesesResultToEachCoordinate(List<Coordinates> coordinatesList, List<Integer> parenthesesList) {
for (int i = 0; i < coordinatesList.size(); i++) {
coordinatesList.get(i).gaussParenthesesResult = parenthesesList.get(i);
}
return coordinatesList;
}
public static float getResultOfGaussMethod(List<Coordinates> coordinatesList) {
float result = 0;
for (Coordinates coordinate : coordinatesList) {
result += coordinate.Y * coordinate.gaussParenthesesResult;
}
return result / -2;
}
}
class Coordinates {
public int X = 0;
public int Y = 0;
public int gaussParenthesesResult = 0;
public Coordinates(int x, int y) {
X = x;
Y = y;
}
@Override
public String toString() {
return "Coordinates{" +
"X=" + X +
", Y=" + Y +
", gaussParenthesesResult=" + gaussParenthesesResult +
"} \n";
}
}
przy tym zadaniu https://pl.spoj.com/problems/BAJTELEK/
Czy jest to problem z wejściem danych?