結果
| 問題 | No.3622 Perfect Matching of Crab |
| コンテスト | |
| ユーザー |
urectanc
|
| 提出日時 | 2026-08-14 21:41:54 |
| 言語 | Rust (1.99.1 + proconio + num + itertools + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 75 ms / 2,000 ms |
| + 667µs | |
| コード長 | 932 bytes |
| 記録 | |
| コンパイル時間 | 11,977 ms |
| コンパイル使用メモリ | 190,240 KB |
| 実行使用メモリ | 13,996 KB |
| 最終ジャッジ日時 | 2026-10-25 08:14:09 |
| 合計ジャッジ時間 | 11,027 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge7_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
use std::collections::HashMap;
use proconio::{fastout, input, marker::Usize1};
#[fastout]
fn main() {
input! { t: usize }
for _ in 0..t {
let ans = solve();
println!("{}", if ans { "Yes" } else { "No" });
}
}
fn solve() -> bool {
input! {
n: usize,
xyc: [(Usize1, Usize1, char); 2* n],
}
let mut count = [0usize; 2];
let mut row = HashMap::new();
let mut col = HashMap::new();
for &(x, y, c) in &xyc {
count[(c == 'y') as usize] += 1;
if c == 'x' {
*row.entry(y).or_insert(0) += 1;
} else {
*col.entry(x).or_insert(0) += 1;
}
}
let d = count[0].abs_diff(count[1]);
if d == 0 {
return true;
}
let pair = if count[0] > count[1] {
row.values().map(|&x| x / 2).sum::<usize>()
} else {
col.values().map(|&x| x / 2).sum::<usize>()
};
2 * pair >= d
}
urectanc