結果
問題 | No.2307 [Cherry 5 th Tune *] Cool 46 |
ユーザー | haihamabossu |
提出日時 | 2023-05-19 22:01:01 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 427 ms / 2,000 ms |
コード長 | 2,993 bytes |
コンパイル時間 | 16,612 ms |
コンパイル使用メモリ | 379,328 KB |
実行使用メモリ | 15,320 KB |
最終ジャッジ日時 | 2024-12-21 02:36:15 |
合計ジャッジ時間 | 51,335 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 190 ms
5,248 KB |
testcase_03 | AC | 186 ms
5,248 KB |
testcase_04 | AC | 187 ms
5,248 KB |
testcase_05 | AC | 179 ms
5,248 KB |
testcase_06 | AC | 183 ms
5,248 KB |
testcase_07 | AC | 139 ms
5,248 KB |
testcase_08 | AC | 204 ms
6,372 KB |
testcase_09 | AC | 211 ms
6,856 KB |
testcase_10 | AC | 174 ms
7,616 KB |
testcase_11 | AC | 259 ms
6,984 KB |
testcase_12 | AC | 170 ms
8,916 KB |
testcase_13 | AC | 327 ms
7,564 KB |
testcase_14 | AC | 216 ms
7,680 KB |
testcase_15 | AC | 158 ms
6,888 KB |
testcase_16 | AC | 269 ms
5,720 KB |
testcase_17 | AC | 218 ms
6,936 KB |
testcase_18 | AC | 333 ms
15,320 KB |
testcase_19 | AC | 382 ms
13,816 KB |
testcase_20 | AC | 356 ms
14,464 KB |
testcase_21 | AC | 372 ms
14,464 KB |
testcase_22 | AC | 342 ms
13,720 KB |
testcase_23 | AC | 354 ms
14,592 KB |
testcase_24 | AC | 386 ms
13,768 KB |
testcase_25 | AC | 376 ms
13,692 KB |
testcase_26 | AC | 336 ms
14,544 KB |
testcase_27 | AC | 360 ms
13,712 KB |
testcase_28 | AC | 366 ms
14,280 KB |
testcase_29 | AC | 361 ms
14,164 KB |
testcase_30 | AC | 385 ms
15,240 KB |
testcase_31 | AC | 347 ms
14,336 KB |
testcase_32 | AC | 342 ms
14,464 KB |
testcase_33 | AC | 344 ms
13,952 KB |
testcase_34 | AC | 375 ms
13,384 KB |
testcase_35 | AC | 389 ms
13,588 KB |
testcase_36 | AC | 371 ms
14,392 KB |
testcase_37 | AC | 368 ms
15,128 KB |
testcase_38 | AC | 321 ms
5,248 KB |
testcase_39 | AC | 427 ms
5,248 KB |
testcase_40 | AC | 305 ms
5,248 KB |
testcase_41 | AC | 332 ms
5,248 KB |
testcase_42 | AC | 391 ms
13,792 KB |
testcase_43 | AC | 384 ms
13,664 KB |
testcase_44 | AC | 347 ms
14,848 KB |
testcase_45 | AC | 339 ms
14,720 KB |
ソースコード
pub mod scanner { pub struct Scanner { buf: Vec<String>, } impl Scanner { pub fn new() -> Self { Self { buf: vec![] } } pub fn new_from(source: &str) -> Self { let source = String::from(source); let buf = Self::split(source); Self { buf } } pub fn next<T: std::str::FromStr>(&mut self) -> T { loop { if let Some(x) = self.buf.pop() { return x.parse().ok().expect(""); } let mut source = String::new(); std::io::stdin().read_line(&mut source).expect(""); self.buf = Self::split(source); } } fn split(source: String) -> Vec<String> { source .split_whitespace() .rev() .map(String::from) .collect::<Vec<_>>() } } } use std::collections::{BTreeMap, BTreeSet, BinaryHeap}; use crate::scanner::Scanner; fn main() { let mut scanner = Scanner::new(); let t: usize = scanner.next(); for _ in 0..t { solve(&mut scanner); } } fn solve(scanner: &mut Scanner) { let n: usize = scanner.next(); let m: usize = scanner.next(); let mut count = BTreeMap::new(); let a: Vec<usize> = (0..n) .map(|_| { let x = scanner.next::<usize>(); *count.entry(x).or_insert(0) += 1; x }) .collect(); let b: Vec<usize> = (0..m) .map(|_| { let x = scanner.next::<usize>(); *count.entry(x).or_insert(0) += 1; x }) .collect(); if n == 0 || m == 0 { println!("Yes"); if n == 0 { for i in 0..m { println!("Blue {}", b[i]); } } else { for i in 0..n { println!("Red {}", a[i]); } } return; } let mut c = BTreeSet::new(); let mut q = BinaryHeap::new(); for (&k, &v) in count.iter() { if v == 2 { c.insert(k); q.push(k); } } let c = c; if c.len() == 0 { println!("No"); return; } println!("Yes"); for i in 0..n { if c.contains(&a[i]) { continue; } else { println!("Red {}", a[i]); } } { let now = q.pop().unwrap(); println!("Red {}", now); println!("Blue {}", now); } for i in 0..m { if c.contains(&b[i]) { continue; } else { println!("Blue {}", b[i]); } } let mut turn = 1; while let Some(now) = q.pop() { if turn == 0 { println!("Red {}", now); println!("Blue {}", now); turn = 1; } else { println!("Blue {}", now); println!("Red {}", now); turn = 0; } } }