complete 1547.rs 1609.rs

This commit is contained in:
2026-03-14 21:06:29 +09:00
parent 106c81d7a3
commit d8c754597f
2 changed files with 106 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
use std::io::{read_to_string, stdin};
fn main() {
let temp = read_to_string(stdin()).unwrap();
let mut iter = temp
.split_ascii_whitespace()
.map(|x| x.parse::<usize>().unwrap());
let n = iter.next().unwrap();
let mut cups = vec![false; 3];
cups[0] = true;
(0..n).for_each(|_| {
let (x, y) = (iter.next().unwrap() - 1, iter.next().unwrap() - 1);
let temp = cups[y];
cups[y] = cups[x];
cups[x] = temp;
});
println!(
"{}",
if cups[0] {
1
} else if cups[1] {
2
} else {
3
}
)
}