結果
| 問題 |
No.628 Tagの勢い
|
| コンテスト | |
| ユーザー |
H20
|
| 提出日時 | 2022-09-09 13:03:39 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 3,042 bytes |
| コンパイル時間 | 14,123 ms |
| コンパイル使用メモリ | 384,040 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-25 09:46:17 |
| 合計ジャッジ時間 | 15,251 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 19 |
コンパイルメッセージ
warning: unused import: `std::fmt`
--> src/main.rs:1:5
|
1 | use std::fmt;
| ^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: unused import: `max`
--> src/main.rs:2:21
|
2 | use std::cmp::{min, max};
| ^^^
warning: unused variable: `i`
--> src/main.rs:102:9
|
102 | for i in 0..n{
| ^ help: if this is intentional, prefix it with an underscore: `_i`
|
= note: `#[warn(unused_variables)]` on by default
warning: unused variable: `ni`
--> src/main.rs:104:13
|
104 | ni: isize,
| ^^
|
help: `ni` is captured in macro and introduced a unused variable
--> src/main.rs:44:13
|
44 | let $var = read_value!($next, $t);
| ^^^^
...
103 | / input! {
104 | | ni: isize,
105 | | m: isize,
106 | | s: isize,
107 | | tag:[String;m]
108 | | }
| |_________- in this macro invocation
= note: this warning originates in the macro `input_inner` which comes from the expansion of the macro `input` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: field `value` is never read
--> src/main.rs:94:5
|
93 | struct MyBool {
| ------ field in this struct
94 | value: bool
| ^^^^^
|
= note: `MyBool` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
= note: `#[warn(dead_code)]` on by default
ソースコード
use std::fmt;
use std::cmp::{min, max};
use std::collections::HashMap;
//USE https://mirrorless-camera.info/column/14417.html
macro_rules! input {
($($r:tt)*) => {
let mut bytes = std::io::Read::bytes(std::io::BufReader::new(std::io::stdin()));
let mut next = move |is_word: bool| -> String{
if is_word {
bytes
.by_ref()
.map(|r|r.unwrap() as char)
.skip_while(|c|c.is_whitespace())
.take_while(|c|!c.is_whitespace())
.collect()
} else {
bytes
.by_ref()
.map(|r|r.unwrap() as char)
.skip_while(|c| c == &'\n')
.take_while(|c| c != &'\n')
.collect()
}
};
input_inner!{next, $($r)*};
};
}
macro_rules! input_inner {
($next:expr) => {};
($next:expr, ) => {};
($next:expr, static $var:ident : $t:tt $($rest:tt)*) => {
$var = read_value!($next, $t);
input_inner!{$next $($rest)*}
};
($next:expr, mut $var:ident : $t:tt $($rest:tt)*) => {
let mut $var = read_value!($next, $t);
input_inner!{$next $($rest)*}
};
($next:expr, $var:ident : $t:tt $($rest:tt)*) => {
let $var = read_value!($next, $t);
input_inner!{$next $($rest)*}
};
}
macro_rules! read_value {
($next:expr, ( $($t:tt),* )) => {
( $(read_value!($next, $t)),* )
};
($next:expr, [ $t:tt ; all ]) => { {
let mut str = $next(false);
str.split_whitespace().map(|it| it.parse::<$t>().unwrap()).collect::<Vec<_>>()
}
};
($next:expr, [ $t:tt ; $len:expr ]) => {
(0..$len as usize).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
};
($next:expr, chars) => {
read_value!($next, String).chars().collect::<Vec<char>>()
};
($next:expr, lines) => {
{
let mut vec = Vec::new();
let mut str = $next(false);
while str != "" {
vec.push(str);
str = $next(false);
}
vec
}
};
($next:expr, line) => {
$next(false)
};
($next:expr, usize1) => {
read_value!($next, usize) - 1
};
($next:expr, $t:ty) => {
$next(true).parse::<$t>().expect("Parse error")
};
}
#[derive(Debug)]
struct MyBool {
value: bool
}
fn main() {
input! {
n: isize
}
let mut score: HashMap<String, isize> = HashMap::new();
for i in 0..n{
input! {
ni: isize,
m: isize,
s: isize,
tag:[String;m]
}
for st in tag{
*score.entry(st).or_default() += s;
}
}
let mut vec: Vec<(_, _)> = score.iter().collect();
vec.sort_by(|a, b| (-a.1).cmp(&(-b.1)).then(a.0.cmp(&b.0)));
for i in 0..min(10,vec.len()){
println!("{} {}",vec[i].0,vec[i].1)
}
}
H20