diff options
| author | omagdy7 <omar.professional8777@gmail.com> | 2023-12-10 15:55:42 +0200 |
|---|---|---|
| committer | omagdy7 <omar.professional8777@gmail.com> | 2023-12-10 15:55:42 +0200 |
| commit | 1ccba7112b334c0887bd349966219b38eb9ccfb9 (patch) | |
| tree | 07be3a04f8bb90569025d2b3a89d48d373333566 /codeforces/Rook/main.rs | |
| parent | beb36b3d4f757bd5ecb9746265926c9f8830b0ab (diff) | |
| download | competitive-programming-1ccba7112b334c0887bd349966219b38eb9ccfb9.tar.xz competitive-programming-1ccba7112b334c0887bd349966219b38eb9ccfb9.zip | |
Removed some empty problems and solved 2 problems in rust
Diffstat (limited to 'codeforces/Rook/main.rs')
| -rw-r--r-- | codeforces/Rook/main.rs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/codeforces/Rook/main.rs b/codeforces/Rook/main.rs new file mode 100644 index 0000000..49953f1 --- /dev/null +++ b/codeforces/Rook/main.rs @@ -0,0 +1,50 @@ +#[allow(dead_code)] +fn read<T: std::str::FromStr>() -> T { + let mut s = String::new(); + std::io::stdin().read_line(&mut s).ok(); + s.trim().parse().ok().unwrap() +} + +#[allow(dead_code)] +fn read_vec<T: std::str::FromStr>() -> Vec<T> { + read::<String>() + .split_whitespace() + .map(|e| e.parse().ok().unwrap()) + .collect() +} + +#[allow(dead_code)] +fn read_mat<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> { + (0..n).map(|_| read_vec()).collect() +} + +fn solve() { + let pos = read::<String>(); + let bytes = pos.as_bytes(); + let (x, y) = (bytes[0], bytes[1]); + for i in 0..8 { + let out = format!("{}{}", (i + 'a' as u8) as char, y as char); + if (out == pos.to_string()) { + continue; + } + println!("{}", format!("{}{}", (i + 'a' as u8) as char, y as char)); + } + for j in 0..8 { + let out = format!("{}{}", x as char, (j + 1 + '0' as u8) as char); + if (out == pos.to_string()) { + continue; + } + println!( + "{}", + format!("{}{}", x as char, (j + 1 + '0' as u8) as char) + ); + } +} + +fn main() { + let mut tt = read::<u64>(); + while tt > 0 { + solve(); + tt -= 1; + } +} |
