Submission #50889116


Source Code Expand

use proconio::input;

fn common_length2(x1: i32, x2: i32) -> i32 {
    let left = x1.max(x2);
    let right = x1.min(x2) + 7;
    if left <= right {
        right - left
    } else {
        0
    }
}

fn common_length3(x1: i32, x2: i32, x3: i32) -> i32 {
    let left = x1.max(x2).max(x3);
    let right = x1.min(x2).min(x3) + 7;
    if left <= right {
        right - left
    } else {
        0
    }
}

fn calc_volume3(a1: i32, b1: i32, c1: i32, a2: i32, b2: i32, c2: i32, a3: i32, b3: i32, c3: i32) -> i32 {
    let dx = common_length3(a1, a2, a3);
    let dy = common_length3(b1, b2, b3);
    let dz = common_length3(c1, c2, c3);
    dx * dy * dz
}

fn calc_volume2(a1: i32, b1: i32, c1: i32, a2: i32, b2: i32, c2: i32) -> i32 {
    let dx = common_length2(a1, a2);
    let dy = common_length2(b1, b2);
    let dz = common_length2(c1, c2);
    dx * dy * dz
}

fn calc_volume(a1: i32, b1: i32, c1: i32, a2: i32, b2: i32, c2: i32, a3: i32, b3: i32, c3: i32) -> (i32, i32, i32) {
    let volume3 = calc_volume3(a1, b1, c1, a2, b2, c2, a3, b3, c3);
    let volume2_1 = calc_volume2(a1, b1, c1, a2, b2, c2);
    let volume2_2 = calc_volume2(a1, b1, c1, a3, b3, c3);
    let volume2_3 = calc_volume2(a2, b2, c2, a3, b3, c3);
    let volume2 = volume2_1 + volume2_2 + volume2_3 - volume3 * 3;
    let volume1 = (7 * 7 * 7 * 3) - volume2 * 2 - volume3 * 3;
    (volume1, volume2, volume3)
}

fn main() {
    input! {
        v1: i32,
        v2: i32,
        v3: i32,
    }

    let mut a1 = 0;
    let mut b1 = 0;
    let mut c1 = 0;

    for a2 in 0..8 {
        for b2 in 0..8 {
            for c2 in 0..8 {
                for a3 in -7..15 {
                    for b3 in -7..15 {
                        for c3 in -7..15 {
                            if calc_volume(a1, b1, c1, a2, b2, c2, a3, b3, c3) == (v1, v2, v3) {
                                println!("Yes");
                                println!("{} {} {} {} {} {} {} {} {}", a1, b1, c1, a2, b2, c2, a3, b3, c3);
                                return;
                            }
                        }
                    }
                }
            }
        }
    }

    println!("No");
}

Submission Info

Submission Time
Task E - 7x7x7
User hyouchun
Language Rust (rustc 1.70.0)
Score 475
Code Size 2246 Byte
Status AC
Exec Time 15 ms
Memory 2072 KiB

Compile Error

warning: variable does not need to be mutable
  --> src/main.rs:54:9
   |
54 |     let mut a1 = 0;
   |         ----^^
   |         |
   |         help: remove this `mut`
   |
   = note: `#[warn(unused_mut)]` on by default

warning: variable does not need to be mutable
  --> src/main.rs:55:9
   |
55 |     let mut b1 = 0;
   |         ----^^
   |         |
   |         help: remove this `mut`

warning: variable does not need to be mutable
  --> src/main.rs:56:9
   |
56 |     let mut c1 = 0;
   |         ----^^
   |         |
   |         help: remove this `mut`

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 475 / 475
Status
AC × 2
AC × 26
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 03_killer_00.txt, 03_killer_01.txt, 04_killer2_00.txt, 04_killer2_01.txt, 05_handmade_00.txt, 05_handmade_01.txt, 05_handmade_02.txt, 05_handmade_03.txt, 05_handmade_04.txt, 05_handmade_05.txt, 05_handmade_06.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 1916 KiB
00_sample_01.txt AC 15 ms 1884 KiB
01_random_00.txt AC 15 ms 1924 KiB
01_random_01.txt AC 15 ms 2068 KiB
01_random_02.txt AC 15 ms 1912 KiB
02_random2_00.txt AC 1 ms 1736 KiB
02_random2_01.txt AC 1 ms 1852 KiB
02_random2_02.txt AC 1 ms 1992 KiB
02_random2_03.txt AC 1 ms 1984 KiB
02_random2_04.txt AC 1 ms 1924 KiB
02_random2_05.txt AC 1 ms 1888 KiB
02_random2_06.txt AC 1 ms 1904 KiB
02_random2_07.txt AC 1 ms 1912 KiB
02_random2_08.txt AC 1 ms 1796 KiB
02_random2_09.txt AC 1 ms 1928 KiB
03_killer_00.txt AC 1 ms 1956 KiB
03_killer_01.txt AC 1 ms 1896 KiB
04_killer2_00.txt AC 3 ms 1888 KiB
04_killer2_01.txt AC 3 ms 1972 KiB
05_handmade_00.txt AC 15 ms 1956 KiB
05_handmade_01.txt AC 15 ms 1912 KiB
05_handmade_02.txt AC 1 ms 1928 KiB
05_handmade_03.txt AC 1 ms 2072 KiB
05_handmade_04.txt AC 0 ms 1964 KiB
05_handmade_05.txt AC 1 ms 1928 KiB
05_handmade_06.txt AC 1 ms 2008 KiB