結果
問題 |
No.2650 [Cherry 6th Tune *] セイジャク
|
ユーザー |
|
提出日時 | 2024-02-23 22:35:56 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,022 bytes |
コンパイル時間 | 20,312 ms |
コンパイル使用メモリ | 379,876 KB |
実行使用メモリ | 18,856 KB |
最終ジャッジ日時 | 2024-09-29 07:36:41 |
合計ジャッジ時間 | 18,914 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 23 WA * 8 |
コンパイルメッセージ
warning: unused variable: `a` --> src/main.rs:9:9 | 9 | let a = temp[1]; | ^ help: if this is intentional, prefix it with an underscore: `_a` | = note: `#[warn(unused_variables)]` on by default
ソースコード
use std::collections::{BTreeSet, HashMap}; fn main() { let mut temp = String::new(); std::io::stdin().read_line(&mut temp).ok(); let temp: Vec<usize> = temp.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let n = temp[0]; let a = temp[1]; let mut x = String::new(); std::io::stdin().read_line(&mut x).ok(); let x: Vec<usize> = x.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let mut t = String::new(); std::io::stdin().read_line(&mut t).ok(); let t: usize = t.trim().parse().unwrap(); let lrs = (0..t).map(|_| { let mut temp = String::new(); std::io::stdin().read_line(&mut temp).ok(); let temp: Vec<usize> = temp.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); (temp[0], temp[1]) }) .collect::<Vec<_>>(); let mut result = vec![-1isize; n]; let mut order = (0..n).collect::<Vec<_>>(); order.sort_by_key(|&i| (x[i], i)); let mut sounds = BTreeSet::new(); let mut start_map = HashMap::new(); let mut end_map = HashMap::new(); for i in 0..t { start_map.insert(lrs[i].0, i as isize +1); end_map.insert(lrs[i].1, i as isize +1); } let starts = (0..t).map(|i| lrs[i].0).collect::<BTreeSet<_>>(); let ends = (0..t).map(|i| lrs[i].1).collect::<BTreeSet<_>>(); let mut pos = 0usize; for idx in 0..n { let i = order[idx]; let next_pos = x[i]; for s in starts.range(pos..=next_pos) { sounds.insert(*start_map.get(s).unwrap_or(&-1)); } for s in ends.range(pos..next_pos) { if let Some(v) = end_map.get(s) { sounds.remove(v); } } result[i] = *sounds.last().unwrap_or(&-1); if idx+1 < n && x[order[idx]] < x[order[idx+1]] { pos = next_pos; } } let result = result.into_iter().map(|v| v.to_string()).collect::<Vec<_>>(); println!("{}", result.join("\n")); }