Submission #787033


Source Code Expand

Copy
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ BinaryHeap, VecDeque };

macro_rules! trace {
    ($var:expr) => ({
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
    })
}
macro_rules! swap { ($a:expr, $b:expr) => ({ let t = $b; $b = $a; $a = t; }) }

fn main() {
    let mut sc = Scanner::new();
    let s : String = sc.cin();
    let i:usize = sc.cin();
    let ans = s.chars().collect::<Vec<_>>()[i-1];

    println!("{}", ans);
}

#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn reserve(&mut self) {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        self.reserve();
        match self.buffer.pop_front().unwrap().parse::<T>() {
            Ok(a) => a,
            Err(_) => panic!("parse err")
        }
    }
    fn get_char(&mut self) -> char {
        self.reserve();
        let head = self.buffer[0].chars().nth(0).unwrap();
        let tail = String::from( &self.buffer[0][1..] );
        if tail.len()>0 { self.buffer[0]=tail } else { self.buffer.pop_front(); }
        head
    }
}

Submission Info

Submission Time
Task A - 添字
User cympfh
Language Rust (1.15.1)
Score 100
Code Size 1572 Byte
Status
Exec Time 4 ms
Memory 380 KB

Compile Error

./Main.rs:1:22: 1:27 warning: unused import, #[warn(unused_imports)] on by default
./Main.rs:1 use std::io::{ self, Write };
                                 ^~~~~
./Main.rs:3:17: 3:20 warning: unused import, #[warn(unused_imports)] on by default
./Main.rs:3 use std::cmp::{ min, max };
                            ^~~
./Main.rs:3:22: 3:25 warning: unused import, #[warn(unused_imports)] on by default
./Main.rs:3 use std::cmp::{ min, max };
                                 ^~~
./Main.rs:4:25: 4:35 warning: unused import, #[warn(unused_imports)] on by default
./Main.rs:4 use std::collections::{ BinaryHeap, VecDeque };
                                    ^~~~~~~~~~

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt
All 100 / 100 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt
Case Name Status Exec Time Memory
0_00.txt 4 ms 380 KB
0_01.txt 4 ms 380 KB
0_02.txt 4 ms 380 KB
0_03.txt 4 ms 380 KB
1_00.txt 4 ms 380 KB
1_01.txt 4 ms 380 KB
1_02.txt 4 ms 380 KB
1_03.txt 4 ms 380 KB