結果

問題 No.2820 Non-Preferred IUPAC Nomenclature
ユーザー aorisoaoriso
提出日時 2024-07-26 22:21:18
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,632 bytes
コンパイル時間 13,150 ms
コンパイル使用メモリ 405,380 KB
実行使用メモリ 83,180 KB
最終ジャッジ日時 2024-07-26 22:21:38
合計ジャッジ時間 19,389 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 1 ms
6,940 KB
testcase_25 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    unused_imports,
    unused_macros,
    dead_code
)]
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;

macro_rules! debug {
  ($($a:expr),* $(,)*) => {
      #[cfg(debug_assertions)]
      eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
  };
}

fn main() {
    input! {
        N:usize, C:[[String;4];N]
    }
    let mut g = vec![vec![]; N];
    for i in 0..N {
        for j in 0..4 {
            if C[i][j] == "H".to_string() {
                continue;
            }
            let Ok(x) = C[i][j].parse::<usize>() else {
                panic!();
            };
            g[i].push(x - 1);
        }
    }
    // 0を根とする。
    let root = "methane".to_string().chars().collect::<Vec<char>>();
    let child = "(methanyl)".to_string().chars().collect::<Vec<char>>();
    let mut name = VecDeque::new();
    dfs(&g, 0, 0, &mut name);
    for &c in name.iter() {
        print!("{c}");
    }
    println!("");
}
fn dfs(g: &Vec<Vec<usize>>, u: usize, p: usize, name: &mut VecDeque<char>) {
    for &v in g[u].iter() {
        if v == p {
            continue;
        }
        dfs(g, v, u, name);
        name.push_front('(');
        name.pop_back();
        name.pop_back();
        name.pop_back();
        name.push_back('y');
        name.push_back('l');
        name.push_back(')');
    }
    name.push_back('m');
    name.push_back('e');
    name.push_back('t');
    name.push_back('h');
    name.push_back('a');
    name.push_back('n');
    name.push_back('e');
}
0