結果
問題 | No.2343 (l+r)/2 |
ユーザー | akakimidori |
提出日時 | 2023-06-09 22:10:47 |
言語 | Rust (1.77.0 + proconio) |
結果 |
RE
|
実行時間 | - |
コード長 | 3,163 bytes |
コンパイル時間 | 12,775 ms |
コンパイル使用メモリ | 389,160 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-10 13:25:16 |
合計ジャッジ時間 | 13,784 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | AC | 4 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | AC | 4 ms
6,940 KB |
testcase_12 | AC | 4 ms
6,940 KB |
testcase_13 | AC | 3 ms
6,948 KB |
testcase_14 | AC | 5 ms
6,940 KB |
コンパイルメッセージ
warning: type alias `Map` is never used --> src/main.rs:45:6 | 45 | type Map<K, V> = BTreeMap<K, V>; | ^^^ | = note: `#[warn(dead_code)]` on by default warning: type alias `Set` is never used --> src/main.rs:46:6 | 46 | type Set<T> = BTreeSet<T>; | ^^^ warning: type alias `Deque` is never used --> src/main.rs:47:6 | 47 | type Deque<T> = VecDeque<T>; | ^^^^^
ソースコード
// ---------- begin Run Length Encoding ---------- fn run_length_encoding<T: Eq>(a: Vec<T>) -> Vec<(T, usize)> { let mut a = a.into_iter().map(|a| (a, 1)).collect::<Vec<_>>(); a.dedup_by(|a, b| { a.0 == b.0 && { b.1 += a.1; true } }); a } // ---------- end Run Length Encoding ---------- // ---------- begin scannner ---------- #[allow(dead_code)] mod scanner { use std::str::FromStr; pub struct Scanner<'a> { it: std::str::SplitWhitespace<'a>, } impl<'a> Scanner<'a> { pub fn new(s: &'a String) -> Scanner<'a> { Scanner { it: s.split_whitespace(), } } pub fn next<T: FromStr>(&mut self) -> T { self.it.next().unwrap().parse::<T>().ok().unwrap() } pub fn next_bytes(&mut self) -> Vec<u8> { self.it.next().unwrap().bytes().collect() } pub fn next_chars(&mut self) -> Vec<char> { self.it.next().unwrap().chars().collect() } pub fn next_vec<T: FromStr>(&mut self, len: usize) -> Vec<T> { (0..len).map(|_| self.next()).collect() } } } // ---------- end scannner ---------- use std::io::Write; use std::collections::*; type Map<K, V> = BTreeMap<K, V>; type Set<T> = BTreeSet<T>; type Deque<T> = VecDeque<T>; fn main() { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); let mut sc = scanner::Scanner::new(&s); let out = std::io::stdout(); let mut out = std::io::BufWriter::new(out.lock()); run(&mut sc, &mut out); } fn run<W: Write>(sc: &mut scanner::Scanner, out: &mut std::io::BufWriter<W>) { /* let mut map = Map::new(); map.insert(vec![1], vec![1f64]); map.insert(vec![0], vec![0f64]); for n in 2..20 { let mut a = vec![0; n]; for i in (0..n).step_by(2) { a[i] = 1; } for _ in 0..2 { let b = a.clone(); let mut s = vec![]; for i in 1..n { let (l, r) = b.split_at(i); let l = Vec::from(l); let r = Vec::from(r); let x = &map[&l]; let y = &map[&r]; for x in x.iter() { for y in y.iter() { s.push((*x + *y) * 0.5); } } } s.sort_by(|a, b| a.partial_cmp(b).unwrap()); s.dedup_by(|a, b| (*a - *b).abs() < 1e-9); if s.iter().any(|s| (*s - 0.5).abs() < 1e-9) { println!("{}: {:?}", n, b); } map.insert(b, s); a.iter_mut().for_each(|a| *a ^= 1); } } */ let t: u32 = sc.next(); for _ in 0..t { let n: usize = sc.next(); let a: Vec<i32> = sc.next_vec(n); let z = run_length_encoding(a); let ans = if z.len() >= 9 || z.len() % 2 == 0 || (z.len() % 2 == 1 && z.iter().any(|p| p.0 == z[1].0 && p.1 > 1)) { "Yes" } else { "No" }; writeln!(out, "{}", ans).ok(); } }