Code Submission Evaluation System Login

Datatähti 2016 alku

Start:2015-09-28 00:00:00
End:2015-10-12 00:00:00
 

Tasks | Scoreboard | Statistics


CSES - Datatähti 2016 alku - Results
History
2015-10-11 23:38:480
2015-10-11 23:29:090
2015-10-02 23:02:320
2015-10-02 22:23:5661
2015-10-02 22:14:550
2015-10-02 16:25:2161
2015-10-02 15:34:1837
2015-10-02 15:28:03
2015-10-02 15:11:1337
2015-10-02 14:59:3137
2015-10-02 14:17:110
2015-10-02 14:12:34
2015-10-02 13:42:010
Task:Lennot
Sender:Maunuliini
Submission time:2015-10-02 14:12:34
Language:Java
Status:COMPILE ERROR

Compiler report

input/Datatahti201641.java:55: error: incompatible types: Object cannot be converted to int
            for(int a:check){
                      ^
input/Datatahti201641.java:69: error: incompatible types: Object cannot be converted to int
            for(int a:check2){
                      ^
Note: input/Datatahti201641.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors

Code

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */


/**
 *
 * @author alexey
 */
import java.util.*; 

public class Datatahti201641 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner scan=new Scanner(System.in);
        
        int city=scan.nextInt();
        int connect=scan.nextInt();
        int[][] cities = new int[city+1][2];
        int i=1;
        while(i<city+1){
            cities[i][0]=Integer.MAX_VALUE;
            cities[i][1]=Integer.MAX_VALUE;
            i++;
        }
        cities[1][0]=0;
        cities[1][1]=0;
      ArrayList<ArrayList<int[]>> connections= new  ArrayList<ArrayList<int[]>>();
      connections.add(new ArrayList());
        for (int j = 0; j < connect; j++) {
            connections.add(new ArrayList<int[]>());
        }
        
        for (int j = 0; j < connect; j++) {
            int a=scan.nextInt();
            int b=scan.nextInt();
            int c=scan.nextInt();
            int[] d =new int[2];
            d[0]=b;
            d[1]=c;
            connections.get(a).add(d);
        }
     
        Set check = new HashSet();
        Set check2 = new HashSet();
        
        check.add(1);
        while(true){
            for(int a:check){
                for(int[] k:connections.get(a)){
                    if(cities[k[0]][0]>k[1]+cities[a][1]){
                        check2.add(k[0]);
                        cities[k[0]][0]=k[1]+cities[a][1];
                    }
                }
            }
            check.clear();
            if(check2.isEmpty()){
                break;
            }
          
            
            for(int a:check2){
                for(int[] k:connections.get(a)){
                    if(cities[k[0]][1]>cities[a][0]){
                        check.add(k[0]);
                        cities[k[0]][1]=cities[a][0]+0;
                    }
                }
            }
        
            check2.clear();
        }
        System.out.println(Math.min(cities[city][0], cities[city][1]));
       
    }
    
}