結果
問題 | No.1643 Not Substring |
ユーザー |
![]() |
提出日時 | 2021-08-13 21:29:23 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 2,443 bytes |
コンパイル時間 | 13,747 ms |
コンパイル使用メモリ | 401,408 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-03 21:32:36 |
合計ジャッジ時間 | 13,261 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 26 |
コンパイルメッセージ
warning: unused variable: `i` --> src/main.rs:10:9 | 10 | for i in 0..=cnt { | ^ help: if this is intentional, prefix it with an underscore: `_i` | = note: `#[warn(unused_variables)]` on by default
ソースコード
#[allow(dead_code)]fn solve(read: &mut snio::Reader<std::io::StdinLock<'_>>) {let s:Vec<_> = read.chars();let mut cnt = 0;for i in 0..s.len() {if s[i] == 'a' {cnt += 1;}}for i in 0..=cnt {print!("a");}println!("");}//use proconio::input;fn main() {let t = std::io::stdin();let mut read = snio::Reader::new(t.lock());let n = 1;for _ in 0..n {solve(&mut read);}}#[allow(dead_code)]pub mod snio {pub struct Reader<R: std::io::BufRead> {reader: R,buf: std::collections::VecDeque<String>,}impl<R: std::io::BufRead> Reader<R> {pub fn new(reader: R) -> Self {Self {reader,buf: std::collections::VecDeque::new(),}}fn load(&mut self) {while self.buf.is_empty() {let mut s = String::new();let length = self.reader.read_line(&mut s).unwrap();if length == 0 {break;}self.buf.extend(s.split_whitespace().map(|s| s.to_owned()));}}pub fn string(&mut self) -> String {self.load();self.buf.pop_front().unwrap_or_else(|| panic!("input ended"))}pub fn char(&mut self) -> char {let string = self.string();let mut chars = string.chars();let res = chars.next().unwrap();assert!(chars.next().is_none(), "invalid input!");res}pub fn chars(&mut self) -> Vec<char> {self.read::<String>().chars().collect()}pub fn read<T: std::str::FromStr>(&mut self) -> Twhere<T as ::std::str::FromStr>::Err: ::std::fmt::Debug,{self.string().parse::<T>().expect("Failed to parse the input.")}}macro_rules! definition_of_reader_of_numbers {($($ty:tt,)*) => {impl <R:std::io::BufRead> Reader<R> {$(#[inline]pub fn $ty (&mut self) -> $ty {self.read::<$ty>()})*}}}definition_of_reader_of_numbers! {u8,u16,u32,u64,usize,i8,i16,i32,i64,isize,}}