結果
| 問題 |
No.1471 Sort Queries
|
| コンテスト | |
| ユーザー |
fukafukatani
|
| 提出日時 | 2021-04-09 21:36:39 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 316 ms / 2,000 ms |
| コード長 | 1,419 bytes |
| コンパイル時間 | 15,281 ms |
| コンパイル使用メモリ | 384,516 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-25 04:32:20 |
| 合計ジャッジ時間 | 19,051 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
コンパイルメッセージ
warning: unused variable: `n`
--> src/main.rs:20:10
|
20 | let (n, q) = (v[0], v[1]);
| ^ help: if this is intentional, prefix it with an underscore: `_n`
|
= note: `#[warn(unused_variables)]` on by default
warning: unused variable: `i`
--> src/main.rs:23:9
|
23 | for i in 0..q {
| ^ help: if this is intentional, prefix it with an underscore: `_i`
ソースコード
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;
use std::ops::Bound::*;
#[allow(unused_macros)]
macro_rules! debug {
($($e:expr),*) => {
#[cfg(debug_assertions)]
$({
let (e, mut err) = (stringify!($e), std::io::stderr());
writeln!(err, "{} = {:?}", e, $e).unwrap()
})*
};
}
fn main() {
let v = read_vec::<usize>();
let (n, q) = (v[0], v[1]);
let s = read::<String>().chars().collect::<Vec<_>>();
let mut queries = vec![];
for i in 0..q {
let v = read_vec::<usize>();
let (l, r, x) = (v[0] - 1, v[1] - 1, v[2] - 1);
queries.push((l, r, x));
}
for (l, r, x) in queries {
let mut count = vec![0; 26];
for i in l..=r {
count[s[i].to_digit(36).unwrap() as usize - 10] += 1;
}
let mut x = x;
for ci in 0..26 {
if x < count[ci] {
println!("{}", std::char::from_digit(ci as u32 + 10, 36).unwrap());
break;
}
x -= count[ci];
}
}
}
fn read<T: std::str::FromStr>() -> T {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
read::<String>()
.split_whitespace()
.map(|e| e.parse().ok().unwrap())
.collect()
}
fukafukatani