結果

問題 No.1439 Let's Compare!!!!
ユーザー RheoTommyRheoTommy
提出日時 2021-03-26 21:50:09
言語 Rust
(1.72.1)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 3,971 bytes
コンパイル時間 3,377 ms
コンパイル使用メモリ 165,856 KB
実行使用メモリ 9,028 KB
最終ジャッジ日時 2023-08-19 15:15:59
合計ジャッジ時間 5,653 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 123 ms
8,932 KB
testcase_11 AC 107 ms
6,348 KB
testcase_12 AC 106 ms
6,076 KB
testcase_13 AC 123 ms
9,028 KB
testcase_14 AC 124 ms
9,024 KB
testcase_15 AC 103 ms
5,852 KB
testcase_16 AC 81 ms
5,852 KB
testcase_17 AC 70 ms
5,792 KB
testcase_18 AC 56 ms
5,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

// # ファイル構成
// - use宣言
// - libモジュール
// - main関数
// - basicモジュール
//
// 常に使うテンプレートライブラリはbasicモジュール内にあります。
// 問題に応じて使うライブラリlibモジュール内にコピペしています。
// ライブラリのコードはこちら → https://github.com/RheoTommy/at_coder
// Twitterはこちら → https://twitter.com/RheoTommy

use std::collections::*;
use std::io::{stdout, BufWriter, Write};

use crate::basic::*;
use crate::lib::*;

pub mod lib {}

fn main() {
    let out = stdout();
    let mut writer = BufWriter::new(out.lock());
    let mut sc = Scanner::new();

    let n = sc.next_usize();
    let mut s = sc
        .next_chars()
        .into_iter()
        .map(|ci| ci.to_digit(10).unwrap() as usize)
        .collect::<Vec<_>>();
    let mut t = sc
        .next_chars()
        .into_iter()
        .map(|ci| ci.to_digit(10).unwrap() as usize)
        .collect::<Vec<_>>();

    let mut map = BTreeMap::new();

    for i in 0..n {
        if s[i] != t[i] {
            map.insert(i, s[i] > t[i]);
        }
    }

    for _ in 0..sc.next_usize() {
        let ci = sc.next_char();
        let x = sc.next_usize() - 1;
        let y = sc.next_usize();
        map.remove(&x);
        if ci == 'S' {
            s[x] = y;
            if s[x] != t[x] {
                map.insert(x, s[x] > t[x]);
            }
        } else {
            t[x] = y;
            if s[x] != t[x] {
                map.insert(x, s[x] > t[x]);
            }
        }

        let max = map.iter().next();
        if let Some((_, &b)) = max {
            if b {
                writeln!(writer, "{}", ">").unwrap();
            } else {
                writeln!(writer, "{}", "<").unwrap();
            }
        } else {
            writeln!(writer, "=").unwrap();
        }
    }
}

pub mod basic {
    pub const U_INF: u64 = (1 << 60) + (1 << 30);
    pub const I_INF: i64 = (1 << 60) + (1 << 30);

    pub struct Scanner {
        buf: std::collections::VecDeque<String>,
        reader: std::io::BufReader<std::io::Stdin>,
    }

    impl Scanner {
        pub fn new() -> Self {
            Self {
                buf: std::collections::VecDeque::new(),
                reader: std::io::BufReader::new(std::io::stdin()),
            }
        }

        fn scan_line(&mut self) {
            use std::io::BufRead;
            let mut flag = 0;
            while self.buf.is_empty() {
                let mut s = String::new();
                self.reader.read_line(&mut s).unwrap();
                let mut iter = s.split_whitespace().peekable();
                if iter.peek().is_none() {
                    if flag >= 5 {
                        panic!("There is no input!");
                    }
                    flag += 1;
                    continue;
                }

                for si in iter {
                    self.buf.push_back(si.to_string());
                }
            }
        }

        pub fn next<T: std::str::FromStr>(&mut self) -> T {
            self.scan_line();
            self.buf
                .pop_front()
                .unwrap()
                .parse()
                .unwrap_or_else(|_| panic!("Couldn't parse!"))
        }

        pub fn next_usize(&mut self) -> usize {
            self.next()
        }

        pub fn next_int(&mut self) -> i64 {
            self.next()
        }

        pub fn next_uint(&mut self) -> u64 {
            self.next()
        }

        pub fn next_chars(&mut self) -> Vec<char> {
            self.next::<String>().chars().collect()
        }

        pub fn next_string(&mut self) -> String {
            self.next()
        }

        pub fn next_char(&mut self) -> char {
            self.next()
        }

        pub fn next_float(&mut self) -> f64 {
            self.next()
        }
    }
}
0