結果
| 問題 |
No.2343 (l+r)/2
|
| コンテスト | |
| ユーザー |
akakimidori
|
| 提出日時 | 2023-06-09 21:54:57 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,097 bytes |
| コンパイル時間 | 10,836 ms |
| コンパイル使用メモリ | 402,644 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2025-01-02 02:55:18 |
| 合計ジャッジ時間 | 11,932 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 7 WA * 7 |
コンパイルメッセージ
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 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() % 2 == 0 || (z.len() > 1 && z.iter().any(|p| p.0 == z[1].0 && p.1 > 1)) {
"Yes"
} else {
"No"
};
writeln!(out, "{}", ans).ok();
}
}
akakimidori