ROUTING JAVA 런타임에러(nonzero return code)

  • chsalm
    chsalm
    import java.io.FileInputStream;
    import java.util.*;
    
    public class Main {
        public static void main(String[] args) throws Exception  {
            // TODO Auto-generated method stub
            Scanner sc = new Scanner(System.in);
            //Scanner sc = new Scanner(new FileInputStream("input.txt"));
            int cases = sc.nextInt();
    
            for(int i=0; i<cases; i++){
                int N=sc.nextInt();
                double[][] arr=new double[N][N];
                int tempN=sc.nextInt();
                for(int j=0; j<tempN; j++){
                    int temp1=sc.nextInt();
                    int temp2=sc.nextInt();
                    double temp3=sc.nextDouble();
                    arr[temp1][temp2]=temp3;
                }
                double[] distance=new double[N];
                distance[0]=1.0;
                for(int j=1; j<N; j++){
                    distance[j]=999999999.9;
                }
                int count=0;
                int[] check=new int[N];
                check[0]=1;
                int level=1;
                while(level!=N){
                    double min=99999999.9;
                    int index=0;
                    for(int j=0; j<N; j++){
                        if(count==j||arr[count][j]==0)continue;
                        if(distance[j]>distance[count]*arr[count][j])
                            distance[j]=distance[count]*arr[count][j];
                        if(check[j]!=1&&min>distance[j])index=j;
                    }
                    check[index]=1;
                    count=index;
                    level++;
                }
                System.out.printf("%.10f\n",distance[N-1]);
            }    
        }
    
    
    }
    

    아무리 봐도 이유를 잘 모르겠습니다...ㅠㅠ


    7년 전
1개의 댓글이 있습니다.
  • JongMan
    JongMan

    코드의 뒤 절반을 주석처리하고 제출해 보시고, 그래서 런타임 에러가 안나면 주석처리되었던 부분의 절반만 주석으로 남기고 제출하는 식으로 이분 검색을 해보시는걸 추천드립니다.


    7년 전 link
  • 정회원 권한이 있어야 커멘트를 다실 수 있습니다. 정회원이 되시려면 온라인 저지에서 5문제 이상을 푸시고, 가입 후 7일 이상이 지나셔야 합니다. 현재 문제를 푸셨습니다.