AtCoder Grand Contest 005

Submission #1574062

Source codeソースコード

use std::io::*;
use std::str::*;
use std::process;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main(){
    let s = read_str();
    let mut sum:i32 = 0;
    let mut ans:i32 = s.len() as i32;

    for i in 0 .. s.len(){
        if(s[i]=='S'){
            sum += 1
        }
        if(s[i]=='T'){
            if(sum > 0){
                sum -=1;
                ans -=2;
            }
        }
    }
    println!("{}",ans);
}
fn read_str() -> Vec<char>{
    let s :String = read();
    s.chars().collect::<Vec<char>>()
}
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().unwrap_or_else(|_| panic!("Faild to parse {}", s))
}

Submission

Task問題 A - STring
User nameユーザ名 uenoku
Created time投稿日時
Language言語 Rust (1.15.1)
Status状態 AC
Score得点 300
Source lengthソースコード長 908 Byte
File nameファイル名
Exec time実行時間 7 ms
Memory usageメモリ使用量 4352 KB

Compiler messageコンパイルメッセージ

warning: unnecessary parentheses around `if` condition, #[warn(unused_parens)] on by default
--> ./Main.rs:13:11
|
13 | if(s[i]=='S'){
| ^^^^^^^^^^^

warning: unnecessary parentheses around `if` condition, #[warn(unused_parens)] on by default
--> ./Main.rs:16:11
|
16 | if(s[i]=='T'){
| ^^^^^^^^^^^

warning: unnecessary parentheses around `if` condition, #[warn(unused_parens)] on by default
--> ./Main.rs:17:15
|
17 | if(sum > 0){
| ^^^^^^^^^

warning: unused import: `std::process`, #[warn(unused_imports)] on by default
--> ./Main.rs:3:5
|
3 | use std::process;
| ^^^^^^^^^^^^

warning: unused import: `std::collections::HashMap`, #[warn(unused_imports)] on by default
--> ./Main.rs:4:5
|
4 | use std::collections::HashMap;
| ^^^^^^^^^^^^^^^^^^^^^^^^^

warning: unused import: `std::collections::VecDeque`, #[warn(unused_imports)] on by default
--> ./Main.rs:5:5
|
5 | use std::collections::VecDeque;
| ...

Test case

Set

Set name Score得点 / Max score Cases
Sample - example0,example1,example2
Subtask1 200 / 200 example0,example1,example2,sub_corner0,sub_corner1,sub_corner2,sub_rand0,handmade0,handmade1
All 100 / 100 corner0,corner1,corner2,example0,example1,example2,handmade0,handmade1,maxrand0,sub_corner0,sub_corner1,sub_corner2,sub_rand0

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
corner0 AC 6 ms 4352 KB
corner1 AC 6 ms 4352 KB
corner2 AC 6 ms 4352 KB
example0 AC 2 ms 4352 KB
example1 AC 2 ms 4352 KB
example2 AC 2 ms 4352 KB
handmade0 AC 2 ms 4352 KB
handmade1 AC 2 ms 4352 KB
maxrand0 AC 7 ms 4352 KB
sub_corner0 AC 2 ms 4352 KB
sub_corner1 AC 2 ms 4352 KB
sub_corner2 AC 2 ms 4352 KB
sub_rand0 AC 2 ms 4352 KB