Submission #16787310


Source Code Expand

Copy
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        h: usize,
        w: usize,
        _: usize,
        s: [Chars; h],
    };
    let mut i = 1;
    let mut d = vec![vec![0; w]; h];
    let mut done = vec![false; h];
    for r in 0..h {
        let mut first = true;
        for c in 0..w {
            if s[r][c] == '#' {
                if first {
                    first = false;
                } else {
                    i += 1;
                }
            }
            d[r][c] = i;
        }
        if !first {
            i += 1;
            done[r] = true;
        }
    }
    let mut first = true;
    let mut skip = 0;
    let mut o = 0;
    for r in 0..h {
        if first {
            if done[r] {
                first = false;
                o = r;
            } else {
                skip += 1;
            }
        } else {
            if done[r] {
                o = r;
            } else {
                for c in 0..w {
                    d[r][c] = d[o][c];
                }
                done[r] = true;
            }
        }
    }
    for r in (0..skip).rev() {
        for c in 0..w {
            d[r][c] = d[skip][c];
        }
    }
    for r in 0..h {
        for c in 0..w {
            print!("{}{}", d[r][c], if c == w - 1 { "\n" } else { " " });
        }
    }
}

Submission Info

Submission Time
Task C - Strawberry Cakes
User bouzuya
Language Rust (1.42.0)
Score 400
Code Size 1348 Byte
Status AC
Exec Time 31 ms
Memory 2996 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 41
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in28.txt, in29.txt, in30.txt, in31.txt, in32.txt, in33.txt, in34.txt, in35.txt, in36.txt, in37.txt, in38.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
in01.txt AC 6 ms 2024 KB
in02.txt AC 2 ms 2056 KB
in03.txt AC 1 ms 2092 KB
in04.txt AC 1 ms 2044 KB
in05.txt AC 2 ms 2092 KB
in06.txt AC 2 ms 1944 KB
in07.txt AC 4 ms 1992 KB
in08.txt AC 1 ms 2068 KB
in09.txt AC 2 ms 2056 KB
in10.txt AC 1 ms 2064 KB
in11.txt AC 2 ms 2020 KB
in12.txt AC 1 ms 2080 KB
in13.txt AC 1 ms 1964 KB
in14.txt AC 1 ms 2012 KB
in15.txt AC 2 ms 2096 KB
in16.txt AC 1 ms 2056 KB
in17.txt AC 29 ms 2940 KB
in18.txt AC 20 ms 2996 KB
in19.txt AC 22 ms 2804 KB
in20.txt AC 24 ms 2876 KB
in21.txt AC 27 ms 2876 KB
in22.txt AC 24 ms 2868 KB
in23.txt AC 6 ms 2092 KB
in24.txt AC 1 ms 2044 KB
in25.txt AC 25 ms 2880 KB
in26.txt AC 23 ms 2936 KB
in27.txt AC 1 ms 1952 KB
in28.txt AC 25 ms 2880 KB
in29.txt AC 22 ms 2800 KB
in30.txt AC 24 ms 2864 KB
in31.txt AC 25 ms 2840 KB
in32.txt AC 27 ms 2932 KB
in33.txt AC 31 ms 2796 KB
in34.txt AC 23 ms 2928 KB
in35.txt AC 22 ms 2844 KB
in36.txt AC 26 ms 2912 KB
in37.txt AC 23 ms 2848 KB
in38.txt AC 29 ms 2872 KB
sample_01.txt AC 3 ms 2120 KB
sample_02.txt AC 1 ms 2052 KB
sample_03.txt AC 1 ms 2056 KB