Submission #44346224


Source Code Expand

import std/os/readline

fun main()
    val [n1, n2, m] = readline().split(" ").map(fn(s) { s.parse-int-default(-1) })
    var al := vector(n1 + n2 + 1, [])
    for (1, m) fn(_)
        val [a, b] = readline().split(" ").map(fn(s) { s.parse-int-default(-1) })
        al[a] := Cons(b, al[a])
        al[b] := Cons(a, al[b])
    var dist := vector(n1 + n2 + 1, -1)
    dist[1] := 0
    dist[n1 + n2] := 0
    var now := [1]
    var new := []
    var d1 := 0
    while { now.is-cons }
        new := []
        foreach (now) fn(v)
            foreach (al[v]) fn(w)
                if dist[w] == -1 then
                    dist[w] := dist[v] + 1
                    new := Cons(w, new)
                    d1 := max(d1, dist[w])
        now := new
    now := [n1 + n2]
    var d2 := 0
    while { now.is-cons }
        new := []
        foreach (now) fn(v)
            foreach (al[v]) fn(w)
                if dist[w] == -1 then
                    dist[w] := dist[v] + 1
                    new := Cons(w, new)
                    d2 := max(d2, dist[w])
        now := new    
    (d1 + d2 + 1).println

Submission Info

Submission Time
Task D - Add One Edge
User iwashisnake
Language Koka (koka 2.4.0)
Score 400
Code Size 1137 Byte
Status AC
Exec Time 189 ms
Memory 34420 KiB

Compile Error

compile: Main.kk
loading: std/core
loading: std/core/types
loading: std/core/hnd
loading: std/os/readline
check  : Main
linking: a
created: .koka/v2.4.0/gcc-drelease/a
created: a.out
add default effect for std/core/exn

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 51
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_small_00.txt, 01_small_01.txt, 01_small_02.txt, 01_small_03.txt, 01_small_04.txt, 01_small_05.txt, 01_small_06.txt, 01_small_07.txt, 01_small_08.txt, 01_small_09.txt, 01_small_10.txt, 01_small_11.txt, 01_small_12.txt, 02_rnd_00.txt, 02_rnd_01.txt, 02_rnd_02.txt, 02_rnd_03.txt, 02_rnd_04.txt, 02_rnd_05.txt, 02_rnd_06.txt, 02_rnd_07.txt, 02_rnd_08.txt, 02_rnd_09.txt, 03_path_00.txt, 03_path_01.txt, 03_path_02.txt, 03_path_03.txt, 04_semilong_00.txt, 04_semilong_01.txt, 04_semilong_02.txt, 04_semilong_03.txt, 04_semilong_04.txt, 04_semilong_05.txt, 04_semilong_06.txt, 04_semilong_07.txt, 04_semilong_08.txt, 04_semilong_09.txt, 05_dense_00.txt, 05_dense_01.txt, 05_dense_02.txt, 05_dense_03.txt, 05_dense_04.txt, 05_dense_05.txt, 05_dense_06.txt, 05_dense_07.txt, 06_star_00.txt, 06_star_01.txt, 06_star_02.txt, 06_star_03.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 2652 KiB
00_sample_01.txt AC 1 ms 2652 KiB
01_small_00.txt AC 1 ms 2652 KiB
01_small_01.txt AC 1 ms 2664 KiB
01_small_02.txt AC 1 ms 2552 KiB
01_small_03.txt AC 1 ms 2668 KiB
01_small_04.txt AC 1 ms 2660 KiB
01_small_05.txt AC 1 ms 2608 KiB
01_small_06.txt AC 1 ms 2616 KiB
01_small_07.txt AC 1 ms 2608 KiB
01_small_08.txt AC 1 ms 2644 KiB
01_small_09.txt AC 1 ms 2724 KiB
01_small_10.txt AC 1 ms 2608 KiB
01_small_11.txt AC 1 ms 2648 KiB
01_small_12.txt AC 1 ms 2652 KiB
02_rnd_00.txt AC 175 ms 29900 KiB
02_rnd_01.txt AC 139 ms 24316 KiB
02_rnd_02.txt AC 183 ms 28240 KiB
02_rnd_03.txt AC 156 ms 25868 KiB
02_rnd_04.txt AC 176 ms 27812 KiB
02_rnd_05.txt AC 109 ms 21884 KiB
02_rnd_06.txt AC 81 ms 17092 KiB
02_rnd_07.txt AC 152 ms 28512 KiB
02_rnd_08.txt AC 91 ms 18536 KiB
02_rnd_09.txt AC 116 ms 22532 KiB
03_path_00.txt AC 184 ms 30892 KiB
03_path_01.txt AC 188 ms 30832 KiB
03_path_02.txt AC 183 ms 30720 KiB
03_path_03.txt AC 179 ms 30776 KiB
04_semilong_00.txt AC 127 ms 23644 KiB
04_semilong_01.txt AC 114 ms 21564 KiB
04_semilong_02.txt AC 142 ms 24756 KiB
04_semilong_03.txt AC 140 ms 24044 KiB
04_semilong_04.txt AC 160 ms 25236 KiB
04_semilong_05.txt AC 175 ms 30168 KiB
04_semilong_06.txt AC 169 ms 28772 KiB
04_semilong_07.txt AC 178 ms 29812 KiB
04_semilong_08.txt AC 173 ms 28972 KiB
04_semilong_09.txt AC 189 ms 30404 KiB
05_dense_00.txt AC 61 ms 13984 KiB
05_dense_01.txt AC 62 ms 13936 KiB
05_dense_02.txt AC 61 ms 13988 KiB
05_dense_03.txt AC 61 ms 13992 KiB
05_dense_04.txt AC 58 ms 13228 KiB
05_dense_05.txt AC 58 ms 13316 KiB
05_dense_06.txt AC 58 ms 13380 KiB
05_dense_07.txt AC 59 ms 13308 KiB
06_star_00.txt AC 151 ms 34420 KiB
06_star_01.txt AC 145 ms 34276 KiB
06_star_02.txt AC 67 ms 20292 KiB
06_star_03.txt AC 66 ms 20252 KiB