Submission #65738144


Source Code Expand

use itertools::iproduct;
use proconio::{input, marker::Bytes};
use std::collections::VecDeque;

fn main() {
    input! {
        h: usize,
        w: usize,
        mut ans: [Bytes; h],
    }
    let mut queue = iproduct!(0..h, 0..w)
        .filter(|&(i, j)| ans[i][j] == b'E')
        .collect::<VecDeque<_>>();
    while let Some((i, j)) = queue.pop_front() {
        for (ni, nj, c) in [
            (i + 1, j, b'^'),
            (i.wrapping_sub(1), j, b'v'),
            (i, j + 1, b'<'),
            (i, j.wrapping_sub(1), b'>'),
        ]
        .into_iter()
        .filter(|&(ni, nj, _)| ni < h && nj < w)
        {
            if ans[ni][nj] == b'.' {
                ans[ni][nj] = c;
                queue.push_back((ni, nj));
            }
        }
    }
    for ans in &ans {
        println!("{}", String::from_utf8_lossy(ans));
    }
}

Submission Info

Submission Time
Task D - Escape Route
User ngtkana
Language Rust (rustc 1.70.0)
Score 400
Code Size 886 Byte
Status AC
Exec Time 30 ms
Memory 12092 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 25
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 02_corner_00.txt, 02_corner_01.txt, 02_corner_02.txt, 02_corner_03.txt, 02_corner_04.txt, 02_corner_05.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 2080 KiB
00_sample_01.txt AC 1 ms 1852 KiB
00_sample_02.txt AC 0 ms 1796 KiB
01_random_00.txt AC 19 ms 11152 KiB
01_random_01.txt AC 16 ms 6920 KiB
01_random_02.txt AC 28 ms 11928 KiB
01_random_03.txt AC 23 ms 5872 KiB
01_random_04.txt AC 20 ms 11188 KiB
01_random_05.txt AC 20 ms 7288 KiB
01_random_06.txt AC 22 ms 11312 KiB
01_random_07.txt AC 26 ms 7980 KiB
01_random_08.txt AC 16 ms 11296 KiB
01_random_09.txt AC 12 ms 3408 KiB
01_random_10.txt AC 19 ms 5496 KiB
01_random_11.txt AC 30 ms 12092 KiB
01_random_12.txt AC 29 ms 11760 KiB
01_random_13.txt AC 22 ms 5828 KiB
01_random_14.txt AC 23 ms 11580 KiB
01_random_15.txt AC 26 ms 7884 KiB
02_corner_00.txt AC 13 ms 3904 KiB
02_corner_01.txt AC 8 ms 3772 KiB
02_corner_02.txt AC 20 ms 11804 KiB
02_corner_03.txt AC 1 ms 1928 KiB
02_corner_04.txt AC 1 ms 1916 KiB
02_corner_05.txt AC 15 ms 3808 KiB