The problem is you are putting every number from the input file into a 
separate line with 
lines.add(thisScanner.next());

And then treat these lines as if they were the original input lines.
A couple of general recommendations:

   1. Stick to the recommended way of reading inputs from the FAQ > Coding
   2. Start with running your code against the given example input (copy 
   the whole input and paste it into your console or create it as a file and 
   pipe it into your program)
   3. Try the same on the remote server using "Show Test Input"
   4. In the unlikely case that it runs locally, but fails remotely, check 
   that you have the correct language chosen, then try to reproduce it with 
   the exact commands they use on the remote (you can find them in FAQ > 
   Platform). Finally, check versions version of compiler/language
   
I think the reason for not giving back the exact error is that they want to 
eliminate the possibility to get any information about the input by clever 
error throwing.


On Tuesday, 7 April 2020 17:55:17 UTC+2, KapyoniK wrote:
>
> To solve Vestigium, I had this code, which worked perfectly on local 
> machine, but give "RE" without any explanation on the contest. This is very 
> disappointing that such a contest is not explicit as to what the problem 
> might be.
>
> import java.util.ArrayList;
>> import java.util.HashSet;
>> import java.util.List;
>> import java.util.Scanner;
>> import java.util.Set;
>>
>> public class Solution {
>>
>>     public static void main(String[] args) {
>>         Scanner thisScanner = new Scanner(System.in);
>>
>>         List<String> lines = new ArrayList<>();
>>
>>         while(thisScanner.hasNext()) {
>>             lines.add(thisScanner.next());
>>         }
>>
>>         int nbTestCases = Integer.parseInt(lines.get(0));
>>         int thisTestCaseNumber = 0;
>>
>>         List<String> subCase = new ArrayList<>();
>>         int subCaseSize = 0;
>>         String outputString = "";
>>
>>         for(int i = 1; i < lines.size(); i++) {
>>             if(subCaseSize == 0) {
>>                 subCaseSize = Integer.parseInt(lines.get(i));
>>             }
>>             else {
>>                 subCase.add(lines.get(i));
>>                 subCaseSize--;
>>                 if(subCaseSize == 0) {
>>                     outputString = computeNumbers(subCase);
>>                     thisTestCaseNumber++;
>>                     System.out.println("Case #" + thisTestCaseNumber + ": 
>> " + outputString);
>>                     nbTestCases--;
>>                     if(nbTestCases == 0) {
>>                         break;
>>                     }
>>                     else {
>>                         subCase.clear();
>>                     }
>>                 }
>>             }
>>         }
>>
>>     }
>>
>>     private static String computeNumbers(List<String> subCase) {
>>
>>         int[][] myIntArray = convertStringArrayToIntArray(subCase);
>>         int arrayTrace = computeMatrixTrace(myIntArray);
>>         int rowDuplicates = computeMatrixRowDups(myIntArray);
>>         int columnDuplicates = computeMatrixColumnsDups(myIntArray);
>>
>>         return "" + arrayTrace + " " + rowDuplicates + " " + 
>> columnDuplicates;
>>     }
>>
>>     private static int computeMatrixColumnsDups(int[][] myIntArray) {
>>         int thisArrayColumnsDups = 0;
>>         int rowLength = myIntArray[0].length;
>>         Set<Integer> nums;
>>
>>         for(int i = 0; i < rowLength; i++) {
>>             nums = new HashSet<>();
>>             for(int j = 0; j < rowLength; j++) {
>>                 nums.add(myIntArray[j][i]);
>>             }
>>             if(nums.size() < rowLength) {
>>                 thisArrayColumnsDups++;
>>             }
>>         }
>>
>>         return thisArrayColumnsDups;
>>     }
>>
>>     private static int computeMatrixRowDups(int[][] myIntArray) {
>>         int thisArrayRowDups = 0;
>>         int rowLength = myIntArray[0].length;
>>         Set<Integer> nums;
>>
>>         for(int i = 0; i < rowLength; i++) {
>>             nums = new HashSet<>();
>>             for(int j = 0; j < rowLength; j++) {
>>                 nums.add(myIntArray[i][j]);
>>             }
>>             if(nums.size() < rowLength) {
>>                 thisArrayRowDups++;
>>             }
>>         }
>>
>>         return thisArrayRowDups;
>>     }
>>
>>     private static int computeMatrixTrace(int[][] myIntArray) {
>>         int thisArrayTrace = 0;
>>         for(int i = 0; i < myIntArray.length; i++) {
>>             thisArrayTrace += myIntArray[i][i];
>>         }
>>         return thisArrayTrace;
>>     }
>>
>>     private static int[][] convertStringArrayToIntArray(List<String> 
>> subCase) {
>>         int arrayDimension = subCase.size();
>>
>>         int[][] myIntArray = new int[arrayDimension][arrayDimension];
>>         for(int i = 0; i < arrayDimension; i++) {
>>             String[] thoseColumns = subCase.get(i).split(" ");
>>             for(int j = 0; j < arrayDimension; j++) {
>>                 myIntArray[i][j] = Integer.parseInt(thoseColumns[j]);
>>             }
>>         }
>>
>>         return myIntArray;
>>     }
>>
>> }
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/cdf310ff-22ec-44db-9736-80f62db0b0ba%40googlegroups.com.

Reply via email to