0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Rust lang) Atcoder ABC380 - A: 123233

Last updated at Posted at 2024-11-24

code

use std::{collections::HashMap, io::{stdin, BufRead}};

// https://atcoder.jp/contests/abc380/tasks/abc380_a
pub fn main(){
    // number: u64
    let std= stdin();
    let mut buf=std.lock().lines();
    let string_input= buf.next().unwrap().unwrap();
    let number_input= string_input.parse::<u64>().unwrap();

    let n_string= number_input.to_string().trim().to_string();
    let v_n: Vec<char>= n_string.chars().collect();
    
    let mut map_one: HashMap<char, u64>= HashMap::new();
    let mut map_two: HashMap<char, u64>= HashMap::new();
    let mut map_three: HashMap<char, u64>= HashMap::new();

    for e_n in v_n {
        match e_n {
            '1' => {
                map_one.insert('1', 1);
            },
            '2' => {
                map_one.insert('2', 1);

                if *(map_one.get(&'2').unwrap()) == 1 {
                    map_two.insert('2', 2);
                }
            },
            '3' => {
                map_one.insert('3',1);

                if *(map_one.get(&'3').unwrap()) == 1 {
                    map_two.insert('3', 2);
                    
                }
                if *(map_two.get(&'3').unwrap()) == 2 {
                    map_three.insert('3', 3);
                }
            },
            _ => { println!("No"); }
        }
    }



    if *(map_one.get(&'1').unwrap()) == 1 
        && *(map_two.get(&'2').unwrap()) == 2 
        && *(map_three.get(&'3').unwrap()) == 3  {
            println!("Yes");
    }
}

Source code

test code

input

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?