結果

問題 No.1468 Colourful Pastel
ユーザー mtwtkmanmtwtkman
提出日時 2021-04-06 18:52:15
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,331 bytes
コンパイル時間 4,532 ms
コンパイル使用メモリ 162,116 KB
実行使用メモリ 14,304 KB
最終ジャッジ日時 2023-09-02 09:45:32
合計ジャッジ時間 3,619 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
4,376 KB
testcase_16 WA -
testcase_17 AC 1 ms
4,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,384 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 WA -
testcase_27 AC 26 ms
14,304 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: field `num` is never read
  --> Main.rs:23:5
   |
22 | struct Input {
   |        ----- field in this struct
23 |     num: usize,
   |     ^^^
   |
   = note: `#[warn(dead_code)]` on by default

warning: 1 warning emitted

ソースコード

diff #

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);
}
0