From 12ed7660748cd6e87aa492e82c7236f3e3068718 Mon Sep 17 00:00:00 2001 From: bouzuya Date: Sat, 24 Dec 2022 22:43:09 +0900 Subject: [PATCH] abc283 a, b, c, d --- abc283/Cargo.lock | 161 ++++++++++++++++++++++++++++++++++++++++++ abc283/Cargo.toml | 14 ++++ abc283/rust-toolchain | 1 + abc283/src/bin/a.rs | 10 +++ abc283/src/bin/b.rs | 27 +++++++ abc283/src/bin/c.rs | 25 +++++++ abc283/src/bin/d.rs | 30 ++++++++ abc283/src/bin/e.rs | 10 +++ abc283/src/bin/ex.rs | 10 +++ abc283/src/bin/f.rs | 10 +++ abc283/src/bin/g.rs | 10 +++ 11 files changed, 308 insertions(+) create mode 100644 abc283/Cargo.lock create mode 100644 abc283/Cargo.toml create mode 100644 abc283/rust-toolchain create mode 100644 abc283/src/bin/a.rs create mode 100644 abc283/src/bin/b.rs create mode 100644 abc283/src/bin/c.rs create mode 100644 abc283/src/bin/d.rs create mode 100644 abc283/src/bin/e.rs create mode 100644 abc283/src/bin/ex.rs create mode 100644 abc283/src/bin/f.rs create mode 100644 abc283/src/bin/g.rs diff --git a/abc283/Cargo.lock b/abc283/Cargo.lock new file mode 100644 index 00000000..e76628dc --- /dev/null +++ b/abc283/Cargo.lock @@ -0,0 +1,161 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "abc283" +version = "0.1.0" +dependencies = [ + "num", + "proconio", + "superslice", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "num" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8536030f9fea7127f841b45bb6243b27255787fb4eb83958aa1ef9d2fdc0c36" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + +[[package]] +name = "num-bigint" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-complex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" +dependencies = [ + "autocfg", + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proconio" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bed4f95f88d84bb8efd51dbc080d463e6ca953f05dfade2e24daf19dd861ccd" +dependencies = [ + "lazy_static", + "proconio-derive", +] + +[[package]] +name = "proconio-derive" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8096c9313b401ca5bf09f93235fdf4fe6dbedc4f64e3968d2688bf89433a6738" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "superslice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab16ced94dbd8a46c82fd81e3ed9a8727dac2977ea869d217bcc4ea1f122e81f" + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" diff --git a/abc283/Cargo.toml b/abc283/Cargo.toml new file mode 100644 index 00000000..ecf01902 --- /dev/null +++ b/abc283/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "abc283" +version = "0.1.0" +edition = "2018" + +# dependencies added to new project +[dependencies] +num = "=0.2.1" +proconio = { version = "=0.3.6", features = ["derive"] } +superslice = "=1.0.0" + +[profile.release] +lto = true +panic = 'abort' diff --git a/abc283/rust-toolchain b/abc283/rust-toolchain new file mode 100644 index 00000000..1933dfa1 --- /dev/null +++ b/abc283/rust-toolchain @@ -0,0 +1 @@ +1.42.0 \ No newline at end of file diff --git a/abc283/src/bin/a.rs b/abc283/src/bin/a.rs new file mode 100644 index 00000000..b80f7531 --- /dev/null +++ b/abc283/src/bin/a.rs @@ -0,0 +1,10 @@ +use proconio::input; + +fn main() { + input! { + a: usize, + b: usize, + }; + let ans = a.pow(b as u32); + println!("{}", ans); +} diff --git a/abc283/src/bin/b.rs b/abc283/src/bin/b.rs new file mode 100644 index 00000000..99a77987 --- /dev/null +++ b/abc283/src/bin/b.rs @@ -0,0 +1,27 @@ +use proconio::{input, marker::Usize1}; + +fn main() { + input! { + n: usize, + mut a: [usize; n], + q: usize, + }; + for _ in 0..q { + input! { + t: usize, + k: Usize1, + } + match t { + 1 => { + input! { + x: usize, + } + a[k] = x; + } + 2 => { + println!("{}", a[k]); + } + _ => unreachable!(), + } + } +} diff --git a/abc283/src/bin/c.rs b/abc283/src/bin/c.rs new file mode 100644 index 00000000..09168b73 --- /dev/null +++ b/abc283/src/bin/c.rs @@ -0,0 +1,25 @@ +use proconio::{input, marker::Chars}; + +fn main() { + input! { + s: Chars, + }; + + let mut count = 0_usize; + let mut zero = false; + for c in s { + if c == '0' { + if zero { + zero = false; + } else { + zero = true; + count += 1; + } + } else { + zero = false; + count += 1; + } + } + let ans = count; + println!("{}", ans); +} diff --git a/abc283/src/bin/d.rs b/abc283/src/bin/d.rs new file mode 100644 index 00000000..55d19ca8 --- /dev/null +++ b/abc283/src/bin/d.rs @@ -0,0 +1,30 @@ +use proconio::{input, marker::Chars}; + +fn main() { + input! { + s: Chars, + }; + let mut boxes = 0_usize; + let mut stack = vec![]; + for (i, c) in s.iter().copied().enumerate() { + match c { + '(' => { + stack.push((i, boxes)); + } + ')' => { + let (_, bits) = stack.pop().unwrap(); + boxes = bits; + } + 'a'..='z' => { + let index = (c as u8 - b'a') as usize; + if (boxes & (1 << index)) != 0 { + println!("No"); + return; + } + boxes |= 1 << index; + } + _ => unreachable!(), + } + } + println!("Yes"); +} diff --git a/abc283/src/bin/e.rs b/abc283/src/bin/e.rs new file mode 100644 index 00000000..2a9506c8 --- /dev/null +++ b/abc283/src/bin/e.rs @@ -0,0 +1,10 @@ +use proconio::{input, marker::Usize1}; + +fn main() { + input! { + n: usize, + a: [Usize1; n], + }; + let ans = n - a.len(); + println!("{}", ans); +} diff --git a/abc283/src/bin/ex.rs b/abc283/src/bin/ex.rs new file mode 100644 index 00000000..2a9506c8 --- /dev/null +++ b/abc283/src/bin/ex.rs @@ -0,0 +1,10 @@ +use proconio::{input, marker::Usize1}; + +fn main() { + input! { + n: usize, + a: [Usize1; n], + }; + let ans = n - a.len(); + println!("{}", ans); +} diff --git a/abc283/src/bin/f.rs b/abc283/src/bin/f.rs new file mode 100644 index 00000000..2a9506c8 --- /dev/null +++ b/abc283/src/bin/f.rs @@ -0,0 +1,10 @@ +use proconio::{input, marker::Usize1}; + +fn main() { + input! { + n: usize, + a: [Usize1; n], + }; + let ans = n - a.len(); + println!("{}", ans); +} diff --git a/abc283/src/bin/g.rs b/abc283/src/bin/g.rs new file mode 100644 index 00000000..2a9506c8 --- /dev/null +++ b/abc283/src/bin/g.rs @@ -0,0 +1,10 @@ +use proconio::{input, marker::Usize1}; + +fn main() { + input! { + n: usize, + a: [Usize1; n], + }; + let ans = n - a.len(); + println!("{}", ans); +}