結果
| 問題 | No.3705 ビバ子とマカロン (Bibako and Macaron) |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2026-09-22 11:04:00 |
| 言語 | Rust (1.97.1 + proconio + num + itertools + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 551 ms / 3,000 ms |
| + 296µs | |
| コード長 | 1,923 bytes |
| 記録 | |
| コンパイル時間 | 851 ms |
| コンパイル使用メモリ | 207,868 KB |
| 実行使用メモリ | 34,692 KB |
| 最終ジャッジ日時 | 2026-09-22 11:04:38 |
| 合計ジャッジ時間 | 36,302 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| 小課題1 | 10 % | AC * 5 |
| 小課題2 | 30 % | AC * 8 |
| 小課題3 | 60 % | AC * 15 |
| 合計 | 100 点 |
ソースコード
#![allow(non_snake_case, unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
use ac_library::{Additive, Segtree};
use proconio::{input, marker::Usize1, marker::Chars};
use itertools::Itertools;
#[allow(unused_macros)]
macro_rules! d {
( $( $x:expr ),* $(,)? ) => {
eprintln!(
concat!( $( stringify!($x), "={:?} " ),* ),
$( $x ),*
);
};
}
#[allow(dead_code)]
fn yn(b: bool) -> &'static str {
if b { "Yes" } else { "No" }
}
fn grid_overlap(a: (usize, usize), b: (usize, usize)) -> Option<(usize, usize)> {
if a.0 <= b.0 && b.0 <= a.1 {
Some((b.0, a.1.min(b.1)))
} else if b.0 <= a.0 && a.0 <= b.1 {
Some((a.0, b.1.min(a.1)))
} else {
None
}
}
fn main() {
input! {
N: usize,
A: [Usize1; N],
Q: usize,
}
let freq = A.iter().counts();
let mut one_segt = Segtree::<Additive<i64>>::new(N);
let mut two_segt = Segtree::<Additive<i64>>::new(N);
for (k, v) in freq.into_iter() {
if v >= 1 {
one_segt.set(*k, 1);
}
if v >= 2 {
two_segt.set(*k, 1);
}
}
let f = |l: usize, r: usize, segt: &Segtree<Additive<i64>>| -> bool {
let res = segt.prod(l..=r) as usize;
res == r-l+1
};
for _ in 0..Q {
input! {
L1: Usize1,
R1: Usize1,
L2: Usize1,
R2: Usize1,
}
let ans = if let Some((ol, or)) = grid_overlap((L1, R1), (L2, R2)) {
let l = L1.min(L2);
let r = R1.max(R2);
let a = f(l, ol, &one_segt);
let b = f(ol, or, &two_segt);
let c = f(or, r, &one_segt);
a && b && c
} else {
let a = f(L1, R1, &one_segt);
let b = f(L2, R2, &one_segt);
a && b
};
println!("{}", yn(ans));
}
}
norioc