CSES - Datatähti 2016 alku - Results
Submission details
Task:Osajono
Sender:Maunuliini
Submission time:2015-10-02 15:29:40 +0300
Language:Java
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.17 s1details
#20.17 s1details
#30.17 s1details
#40.17 s1details
#50.17 s1details
#60.18 s2details
#70.17 s2details
#80.17 s2details
#90.19 s2details
#100.18 s2details
#110.19 s3details
#120.18 s3details
#130.19 s3details
#140.18 s3details
#150.18 s3details

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 cfg=new Scanner(System.in);
        IO io =new IO();
        
        int city=io.nextInt();
        int connect=io.nextInt();
        long[][] cities = new long[city+1][2];
        int i=1;
        while(i<city+1){
            cities[i][0]=Long.MAX_VALUE;
            cities[i][1]=Long.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 < city; j++) {
            connections.add(new ArrayList<int[]>());
        }
        
        for (int j = 0; j < connect; j++) {
            int a=io.nextInt();
            int b=io.nextInt();
            int c=io.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(Object b:check){
                int a=(Integer) b;
                for(int[] k:connections.get(a)){
                    long x=cities[k[0]][0];
                    long y=k[1]+cities[a][1];
                    
                    if(x>y){
                        check2.add(k[0]);
                        cities[k[0]][0]=y;
                    }
                }
            }
            check.clear();
            if(check2.isEmpty()){
                break;
            }
          
            
            for(Object c:check2){
                int a= (Integer) c;
                for(int[] k:connections.get(a)){
                    long x=cities[k[0]][1];
                    long y=cities[a][0];
                    if(x>y){
                        check.add(k[0]);
                        cities[k[0]][1]=y;
                    }
                }
            }
            
        if(check.isEmpty()){
                break;
            }
            check2.clear();
        }
        
        io.println(Math.min(cities[city][0], cities[city][1]));
       io.close();
    }
    
}

Test details

Test 1

Group: 1

Verdict:

input
BBBAABBBAAAABBAAAABAABAABBBBBB...

correct output
2554

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Datatahti201641.main(Datatahti201641.java:24)

Test 2

Group: 1

Verdict:

input
GDFVYWQCZAFGICSXOSWBZMGPDBSSVL...

correct output
299

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Datatahti201641.main(Datatahti201641.java:24)

Test 3

Group: 1

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAZAAAA...

correct output
4314

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Datatahti201641.main(Datatahti201641.java:24)

Test 4

Group: 1

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
4231

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Datatahti201641.main(Datatahti201641.java:24)

Test 5

Group: 1

Verdict:

input
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ...

correct output
5050

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Datatahti201641.main(Datatahti201641.java:24)

Test 6

Group: 2

Verdict:

input
BBABABBBABBAABBABBABAABAAABABA...

correct output
6253029

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Datatahti201641.main(Datatahti201641.java:24)

Test 7

Group: 2

Verdict:

input
RBKJMLDVQMKHYKCNDIVVKOMFUXTFMG...

correct output
485173

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Datatahti201641.main(Datatahti201641.java:24)

Test 8

Group: 2

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
12427725

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Datatahti201641.main(Datatahti201641.java:24)

Test 9

Group: 2

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
12467549

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Datatahti201641.main(Datatahti201641.java:24)

Test 10

Group: 2

Verdict:

input
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ...

correct output
12502500

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Datatahti201641.main(Datatahti201641.java:24)

Test 11

Group: 3

Verdict:

input
BAAAAABABBABAABAABABABBBABBAAB...

correct output
2500051369

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Datatahti201641.main(Datatahti201641.java:24)

Test 12

Group: 3

Verdict:

input
ABBURXDRVXAYBPXXOQZNYHLWGUEEWR...

correct output
192407124

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Datatahti201641.main(Datatahti201641.java:24)

Test 13

Group: 3

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
4998050400

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Datatahti201641.main(Datatahti201641.java:24)

Test 14

Group: 3

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
4998850144

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Datatahti201641.main(Datatahti201641.java:24)

Test 15

Group: 3

Verdict:

input
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ...

correct output
5000050000

user output
(empty)

Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int.
	at IO.nextInt(IO.java:111)
	at Datatahti201641.main(Datatahti201641.java:24)