| Task: | Sorting coins |
| Sender: | aalto25c_004 |
| Submission time: | 2025-09-17 17:49:58 +0300 |
| Language: | Rust (2021) |
| Status: | COMPILE ERROR |
Compiler report
error[E0412]: cannot find type `HashSet` in this scope --> input/code.rs:35:13 | 35 | let hs: HashSet<usize> = HashSet::from_iter(c.iter().cloned()); | ^^^^^^^ not found in this scope | help: consider importing this struct | 1 + use std::collections::HashSet; | error[E0433]: failed to resolve: use of undeclared type `HashSet` --> input/code.rs:35:30 | 35 | let hs: HashSet<usize> = HashSet::from_iter(c.iter().cloned()); | ^^^^^^^ use of undeclared type `HashSet` | help: consider importing this struct | 1 + use std::collections::HashSet; | error[E0412]: cannot find type `HashMap` in this scope --> input/code.rs:39:19 | 39 | let mut hole: HashMap<usize, usize> = HashMap::new(); | ^^^^^^^ not found in this scope | help: consider importing this struct | 1 + use std::collections::HashMap; | error[E0433]: failed to resolve: use of undeclared type `HashMap` --> inpu...
Code
use std::cmp::{max, min};
use std::collections::VecDeque;
use std::io::{self, Read};
macro_rules! input {
($it: expr) => {
$it.next().unwrap().parse().unwrap()
};
($it: expr, $T: ty) => {
$it.next().unwrap().parse::<$T>().unwrap()
};
}
/*
mod classes;
mod homework;
fn main() {
// println!("{}", "-".repeat(20));
classes::c06::task1();
// homework::hw2::task2();
// println!("{}", "-".repeat(20));
}
// */
fn main() {
let mut buf = String::new();
io::stdin().read_to_string(&mut buf).unwrap();
let mut it = buf.split_whitespace();
let (n, m): (usize, usize) = (input!(it), input!(it));
let c: Vec<usize> = (0..n).map(|_| input!(it)).collect();
let h: Vec<usize> = (0..n).map(|_| input!(it)).collect();
let hs: HashSet<usize> = HashSet::from_iter(c.iter().cloned());
let mut v = Vec::from_iter(hs);
v.sort();
let mut hole: HashMap<usize, usize> = HashMap::new();
let mut i = 0;
for j in 0..h.len() {
while i < v.len() && v[i]<=h[j] {
// println!("{}:{}", v[i], i);
hole.insert(v[i], j);
i+=1;
}
}
for x in c {
print!("{} ", 1+hole.get(&x).unwrap())
}
}
