結果

問題 No.1159 Sashiming String
ユーザー phsplsphspls
提出日時 2020-08-12 16:42:34
言語 Rust
(1.77.0)
結果
RE  
実行時間 -
コード長 766 bytes
コンパイル時間 1,484 ms
コンパイル使用メモリ 157,680 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-18 00:43:57
合計ジャッジ時間 1,759 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 3 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 3 ms
6,940 KB
testcase_09 AC 3 ms
6,944 KB
testcase_10 RE -
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 0 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let s: Vec<char> = s.trim().chars().collect();

    let mut starts: Vec<usize> = vec![];
    let mut ends: Vec<usize> = vec![];
    for i in 0..s.len()-2 {
        if s[i] == 'S' { starts.push(i); }
        if s[i] == 'i' && s[i+1] == 'n' && s[i+2] == 'g' {
            ends.push(i);
        }
    }
    let mut result: usize = 0;
    let mut eidx: usize = 0;
    let elen = ends.len();
    for sidx in starts.iter() {
        let temp = eidx;
        for j in temp..elen {
            if sidx < &ends[j] {
                result += elen - j;
                break;
            } else {
                eidx += 1;
            }
        }
    }
    println!("{}", result);
}
0