結果

問題 No.1159 Sashiming String
ユーザー bluemeganebluemegane
提出日時 2021-05-19 18:26:43
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 1,009 bytes
コンパイル時間 1,032 ms
コンパイル使用メモリ 113,300 KB
実行使用メモリ 27,376 KB
最終ジャッジ日時 2024-04-18 04:47:40
合計ジャッジ時間 2,118 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
26,328 KB
testcase_01 AC 25 ms
26,568 KB
testcase_02 AC 30 ms
22,960 KB
testcase_03 AC 30 ms
25,564 KB
testcase_04 AC 31 ms
24,620 KB
testcase_05 AC 34 ms
27,376 KB
testcase_06 AC 31 ms
24,776 KB
testcase_07 AC 31 ms
23,088 KB
testcase_08 AC 38 ms
26,160 KB
testcase_09 AC 38 ms
26,012 KB
testcase_10 AC 21 ms
23,900 KB
testcase_11 AC 23 ms
25,672 KB
testcase_12 AC 26 ms
24,664 KB
testcase_13 AC 28 ms
24,536 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System.Collections.Generic;
using System;

public class Hello
{
    static void Main()
    {
        var s = Console.ReadLine().Trim();
        if (s.Length < 4) Console.WriteLine(0);
        else getAns(s);
    }
    static void getAns(string s)
    {
        var ans = 0L;
        var ping = searchING(s);
        var ps = seachS(s);
        foreach (var x in ping) ans += ps[x - 1];
        Console.WriteLine(ans);
    }
    static int[] seachS(string s)
    {
        var sL = s.Length;
        var res = new int[sL];
        res[0] = s[0] == 'S' ? 1 : 0;
        for (int i = 1; i < sL; i++) res[i] = s[i] == 'S' ? res[i - 1] + 1 : res[i - 1];
        return res;
    }
    static List<int> searchING(string s)
    {
        var res = new List<int>();
        var sL = s.Length;
        var p = 0;
        while (p < sL)
        {
            var p2 = s.IndexOf("ing", p);
            if (p2 != -1) res.Add(p2);
            else break;
            p = p2 + 3;
        }
        return res;
    }
}
0