Блог пользователя rkat7

Автор rkat7, история, 13 дней назад, По-английски

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.

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
13 дней назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

maybe that your compiler is old

»
12 дней назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

sometimes java sucks i also got so many problems like this

»
12 дней назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

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".