rkat7's blog

By rkat7, history, 13 days ago, In English

I hope it is ok to be pasting the code as it is the very first problem.

import java.util.*;
public class Ladders1{

    public static void main(){
        Scanner sc = new Scanner(System.in).useDelimiter("\n");
        int t = sc.nextInt();
        int a=0,b=0,c=0;
        for(int i=0;i<t;i++){
            String cords = sc.next();
            String[] xyz = cords.split(" ",0);
            a+=Integer.parseInt(xyz[0]);
            b+=Integer.parseInt(xyz[1]);
            c+=Integer.parseInt(xyz[2]);


        }

        if(a==0 && b==0 && c==0){
            System.out.println("YES");
        } else{
            System.out.println("NO");
        }

    }


}

Would really appreciate your input as I've been trying to find the issue to no avail.

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
13 days ago, # |
  Vote: I like it 0 Vote: I do not like it

maybe that your compiler is old

  • »
    »
    13 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I don't think so. Because both use java8

»
13 days ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

sometimes java sucks i also got so many problems like this

»
12 days ago, # |
  Vote: I like it +1 Vote: I do not like it

Don't use delimiter. Just read your coordinates using sc.nextInt() three times, it can itself skip all new-line characters and spaces.

I think that the issue with your case is that Codeforces uses Windows, so the endline is "\r\n".