Submission #44338567


Source Code Expand

import std/os/readline
import std/text/parse

fun pints()
  many
    whitespace0()
    pint()

fun main()
    val [n1, n2, m] = readline().slice.parse(pints).maybe.default([])
    var al := vector(n1 + n2 + 1, [])
    for (1, m) fn(_)
        val [a, b] = readline().slice.parse(pints).maybe.default([])
        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 0
Code Size 1188 Byte
Status TLE
Exec Time 2183 ms
Memory 245816 KiB

Compile Error

compile: Main.kk
loading: std/core
loading: std/core/types
loading: std/core/hnd
loading: std/os/readline
loading: std/text/parse
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 0 / 400
Status
AC × 2
AC × 39
TLE × 12
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 2772 KiB
00_sample_01.txt AC 1 ms 2788 KiB
01_small_00.txt AC 1 ms 2640 KiB
01_small_01.txt AC 1 ms 2768 KiB
01_small_02.txt AC 1 ms 2580 KiB
01_small_03.txt AC 1 ms 2768 KiB
01_small_04.txt AC 1 ms 2684 KiB
01_small_05.txt AC 1 ms 2632 KiB
01_small_06.txt AC 1 ms 2672 KiB
01_small_07.txt AC 1 ms 2688 KiB
01_small_08.txt AC 1 ms 2768 KiB
01_small_09.txt AC 1 ms 2740 KiB
01_small_10.txt AC 1 ms 2768 KiB
01_small_11.txt AC 1 ms 2696 KiB
01_small_12.txt AC 1 ms 2744 KiB
02_rnd_00.txt TLE 2042 ms 230088 KiB
02_rnd_01.txt AC 1653 ms 186848 KiB
02_rnd_02.txt AC 1896 ms 215112 KiB
02_rnd_03.txt AC 1746 ms 198312 KiB
02_rnd_04.txt AC 1890 ms 214696 KiB
02_rnd_05.txt AC 1408 ms 160796 KiB
02_rnd_06.txt AC 1033 ms 120036 KiB
02_rnd_07.txt TLE 2094 ms 237108 KiB
02_rnd_08.txt AC 1124 ms 130536 KiB
02_rnd_09.txt AC 1432 ms 166644 KiB
03_path_00.txt TLE 2168 ms 242284 KiB
03_path_01.txt TLE 2183 ms 242256 KiB
03_path_02.txt TLE 2175 ms 242172 KiB
03_path_03.txt TLE 2159 ms 242296 KiB
04_semilong_00.txt AC 1594 ms 181100 KiB
04_semilong_01.txt AC 1432 ms 164340 KiB
04_semilong_02.txt AC 1673 ms 190156 KiB
04_semilong_03.txt AC 1628 ms 184444 KiB
04_semilong_04.txt AC 1705 ms 194592 KiB
04_semilong_05.txt TLE 2081 ms 233556 KiB
04_semilong_06.txt TLE 2014 ms 226608 KiB
04_semilong_07.txt TLE 2044 ms 230584 KiB
04_semilong_08.txt AC 2000 ms 223696 KiB
04_semilong_09.txt TLE 2119 ms 237100 KiB
05_dense_00.txt AC 949 ms 115272 KiB
05_dense_01.txt AC 944 ms 115012 KiB
05_dense_02.txt AC 946 ms 115224 KiB
05_dense_03.txt AC 928 ms 115228 KiB
05_dense_04.txt AC 890 ms 109032 KiB
05_dense_05.txt AC 871 ms 109212 KiB
05_dense_06.txt AC 883 ms 109240 KiB
05_dense_07.txt AC 876 ms 109196 KiB
06_star_00.txt TLE 2042 ms 245788 KiB
06_star_01.txt TLE 2046 ms 245816 KiB
06_star_02.txt AC 994 ms 125996 KiB
06_star_03.txt AC 989 ms 126008 KiB