結果
| 問題 |
No.1468 Colourful Pastel
|
| ユーザー |
|
| 提出日時 | 2021-04-06 18:52:15 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,331 bytes |
| コンパイル時間 | 11,065 ms |
| コンパイル使用メモリ | 403,892 KB |
| 実行使用メモリ | 14,124 KB |
| 最終ジャッジ日時 | 2024-06-11 16:30:53 |
| 合計ジャッジ時間 | 12,272 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 WA * 20 |
コンパイルメッセージ
warning: field `num` is never read
--> src/main.rs:23:5
|
22 | struct Input {
| ----- field in this struct
23 | num: usize,
| ^^^
|
= note: `#[warn(dead_code)]` on by default
ソースコード
mod p1468 {
use std::collections::BTreeSet;
fn gather(v: Vec<String>) -> BTreeSet<String> {
v.into_iter().fold(BTreeSet::new(), |mut acc, s| {
acc.insert(s);
acc
})
}
pub fn solve(begin: Vec<String>, after: Vec<String>) -> String {
let begin_set = gather(begin);
let after_set = gather(after);
let sub = &begin_set ^ &after_set;
if sub.is_empty() {
begin_set
} else {
sub
}.iter().collect::<Vec<_>>()[0].to_owned()
}
}
struct Input {
num: usize,
begin: Vec<String>,
after: Vec<String>,
}
impl Input {
fn readline(len: usize) -> Vec<String> {
use std::io::{self, BufRead};
let stdin = io::stdin();
let lines = stdin.lock().lines().map(|l| l.unwrap().to_string());
lines.take(len).collect()
}
fn accept(len: usize) -> Self {
let lines = Self::readline(len);
let num = lines[0].parse::<usize>().unwrap();
let begin = lines[1].split(" ").map(|s| s.to_string()).collect::<Vec<_>>();
let after = lines[2].split(" ").map(|s| s.to_string()).collect::<Vec<_>>();
Self {
num,
begin,
after,
}
}
}
fn main() {
let args = Input::accept(3);
let result = p1468::solve(args.begin, args.after);
println!("{}", result);
}