aboutsummaryrefslogtreecommitdiff
path: root/codeforces/YetAnotherBrokenKeoard
diff options
context:
space:
mode:
authoromagdy7 <omar.professional8777@gmail.com>2023-12-10 15:55:42 +0200
committeromagdy7 <omar.professional8777@gmail.com>2023-12-10 15:55:42 +0200
commit1ccba7112b334c0887bd349966219b38eb9ccfb9 (patch)
tree07be3a04f8bb90569025d2b3a89d48d373333566 /codeforces/YetAnotherBrokenKeoard
parentbeb36b3d4f757bd5ecb9746265926c9f8830b0ab (diff)
downloadcompetitive-programming-1ccba7112b334c0887bd349966219b38eb9ccfb9.tar.xz
competitive-programming-1ccba7112b334c0887bd349966219b38eb9ccfb9.zip
Removed some empty problems and solved 2 problems in rust
Diffstat (limited to 'codeforces/YetAnotherBrokenKeoard')
-rw-r--r--codeforces/YetAnotherBrokenKeoard/main.rs59
-rw-r--r--codeforces/YetAnotherBrokenKeoard/main_input0.txt13
-rw-r--r--codeforces/YetAnotherBrokenKeoard/main_output0.txt12
-rw-r--r--codeforces/YetAnotherBrokenKeoard/rust-project.json11
4 files changed, 95 insertions, 0 deletions
diff --git a/codeforces/YetAnotherBrokenKeoard/main.rs b/codeforces/YetAnotherBrokenKeoard/main.rs
new file mode 100644
index 0000000..e39fbd5
--- /dev/null
+++ b/codeforces/YetAnotherBrokenKeoard/main.rs
@@ -0,0 +1,59 @@
+#[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 inp = read::<String>();
+ let s = inp.as_bytes();
+ let mut marks = vec![true; s.len()];
+ let mut rmost_l = vec![s.iter().position(|&x| x.is_ascii_lowercase()).unwrap_or(0)];
+ let mut rmost_h = vec![s.iter().position(|&x| x.is_ascii_uppercase()).unwrap_or(0)];
+ for (i, &c) in s.iter().enumerate() {
+ match c as char {
+ 'b' => {
+ marks[i] = false;
+ marks[rmost_l.pop().unwrap_or(i)] = false;
+ }
+ 'B' => {
+ marks[i] = false;
+ marks[rmost_h.pop().unwrap_or(i)] = false;
+ }
+ _ => {}
+ };
+ if c.is_ascii_uppercase() && c != 'B' as u8 {
+ rmost_h.push(i);
+ } else if c.is_ascii_lowercase() && c != 'b' as u8 {
+ rmost_l.push(i);
+ }
+ }
+ let ans = s
+ .iter()
+ .zip(marks.iter())
+ .filter_map(|(&x, include)| include.then_some(x as char))
+ .collect::<String>();
+ println!("{}", ans)
+}
+
+fn main() {
+ let mut tt = read::<u64>();
+ while tt > 0 {
+ solve();
+ tt -= 1;
+ }
+}
diff --git a/codeforces/YetAnotherBrokenKeoard/main_input0.txt b/codeforces/YetAnotherBrokenKeoard/main_input0.txt
new file mode 100644
index 0000000..104142d
--- /dev/null
+++ b/codeforces/YetAnotherBrokenKeoard/main_input0.txt
@@ -0,0 +1,13 @@
+12
+ARaBbbitBaby
+YetAnotherBrokenKeyboard
+Bubble
+Improbable
+abbreviable
+BbBB
+BusyasaBeeinaBedofBloomingBlossoms
+CoDEBARbIES
+codeforces
+bobebobbes
+b
+TheBBlackbboard
diff --git a/codeforces/YetAnotherBrokenKeoard/main_output0.txt b/codeforces/YetAnotherBrokenKeoard/main_output0.txt
new file mode 100644
index 0000000..5d42696
--- /dev/null
+++ b/codeforces/YetAnotherBrokenKeoard/main_output0.txt
@@ -0,0 +1,12 @@
+ity
+YetnotherrokenKeoard
+le
+Imprle
+revile
+
+usyasaeeinaedofloominglossoms
+CDARIES
+codeforces
+es
+
+helaoard
diff --git a/codeforces/YetAnotherBrokenKeoard/rust-project.json b/codeforces/YetAnotherBrokenKeoard/rust-project.json
new file mode 100644
index 0000000..a195582
--- /dev/null
+++ b/codeforces/YetAnotherBrokenKeoard/rust-project.json
@@ -0,0 +1,11 @@
+{
+ "sysroot": "/home/omar/.rustup/toolchains/stable-x86_64-unknown-linux-gnu",
+ "sysroot_src": "/home/omar/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/",
+ "crates": [
+ {
+ "root_module": "main.rs",
+ "edition": "2021",
+ "deps": []
+ }
+ ]
+}