题解 | #简单错误记录#
简单错误记录
https://www.nowcoder.com/practice/2baa6aba39214d6ea91a2e03dff3fbeb
use std::io::{self, *}; use std::collections::HashMap; fn main() { let stdin = io::stdin(); let mut m: HashMap<String, u8> = HashMap::new(); let mut q: Vec<String> = Vec::new(); unsafe { for line in stdin.lock().lines() { let ll = line.unwrap(); let res: Vec<&str> = ll.split(" ").collect(); let paths: Vec<&str> = res[0].split("\\").collect(); let fname = paths.last().unwrap(); let start = ll.len() - 1 - res[1].len() - fname.len().min(16); let key = ll[start..ll.len()].to_string(); if let Some(_) = q.iter().find(|&i| (*i).eq(&key)) {} else { q.push(key.clone()) } m.entry(key).and_modify(|i| *i += 1).or_insert(1); } for i in (if q.len() > 8 {q.len() - 8} else {0})..q.len() { println!("{} {}", q[i], m[&q[i]]); } } }