結果
| 問題 | No.3622 Perfect Matching of Crab |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-14 21:32:03 |
| 言語 | Rust (1.94.0 + proconio + num + itertools) |
| 結果 |
AC
|
| 実行時間 | 81 ms / 2,000 ms |
| + 769µs | |
| コード長 | 904 bytes |
| 記録 | |
| コンパイル時間 | 12,387 ms |
| コンパイル使用メモリ | 203,440 KB |
| 実行使用メモリ | 9,388 KB |
| 最終ジャッジ日時 | 2026-08-14 21:32:19 |
| 合計ジャッジ時間 | 4,498 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 16 |
ソースコード
use proconio::input;
use std::collections::HashSet;
fn solve() {
input! {
n: usize,
xyc: [(i32, i32, char); 2 * n],
}
let mut cntx = 0;
let mut stx = HashSet::new();
let mut cnty = 0;
let mut sty = HashSet::new();
for (x, y, c) in xyc {
match c {
'x' => {
cntx += 1;
if stx.contains(&y) {
stx.remove(&y);
}
else {
stx.insert(y);
}
},
'y' => {
cnty += 1;
if sty.contains(&x) {
sty.remove(&x);
}
else {
sty.insert(x);
}
},
_ => unreachable!(),
}
}
let ans = if stx.len() < sty.len() {
sty.len() - stx.len() <= cntx - stx.len()
}
else {
stx.len() - sty.len() <= cnty - sty.len()
};
println!("{}", if ans {"Yes"} else {"No"});
}
fn main() {
input! {
t: usize,
}
for _ in 0..t {
solve();
}
}