結果

問題 No.1471 Sort Queries
ユーザー Masaki Kitaguchi
提出日時 2022-02-02 22:34:18
言語 Rust
(1.83.0 + proconio)
結果
TLE  
実行時間 -
コード長 1,065 bytes
コンパイル時間 10,879 ms
コンパイル使用メモリ 379,332 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-06-11 09:37:13
合計ジャッジ時間 22,077 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30 TLE * 1 -- * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#[macro_export]
macro_rules! setup {
    { mut $input:ident: SplitWhitespace $(,)? } => {
        use std::io::Read;
        let mut buf = String::new();
        std::io::stdin().read_to_string(&mut buf).ok();
        let mut $input = buf.split_whitespace();
    };
}

#[macro_export]
macro_rules! parse_next {
    ($str_iter:expr) => {
        $str_iter.next().unwrap().parse().ok().unwrap()
    };
}

#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};

fn main() {
    setup! { mut input: SplitWhitespace };

    let _n: usize = parse_next!(input);
    let q: usize = parse_next!(input);
    let s: String = parse_next!(input);
    let lrx: Vec<(usize, usize, usize)> = (0..q)
        .map(|_| (parse_next!(input), parse_next!(input), parse_next!(input)))
        .collect();

    for i in 0..q {
        let (l, r, x) = lrx[i];

        let ans = (|| {
            let mut cs = s[(l - 1)..=(r - 1)].to_owned().chars().collect::<Vec<_>>();
            cs.sort();
            cs[x - 1]
        })();

        println!("{}", ans);
    }
}
0