示例#1
0
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();

        var dp = new long[n];

        dp[0] = 1;

        for (int i = 1; i < n; i++)
        {
            var cum = new CumSum(dp);
            var t   = new long[n];
            if (s[i - 1] == '>')
            {
                for (int j = 0; j <= i; j++)
                {
                    t[j] = cum.Sum(j, i);
                }
            }
            else
            {
                for (int j = 0; j <= i; j++)
                {
                    t[j] = cum.Sum(0, j);
                }
            }
            dp = Array.ConvertAll(t, x => x % M);
        }
        Console.WriteLine(dp.Sum() % M);
    }
示例#2
0
    static void Main()
    {
        var(n, qc) = Read2();
        var s  = Console.ReadLine();
        var qs = Array.ConvertAll(new bool[qc], _ => Read2());

        var cs = new CumSum(Array.ConvertAll(s.ToCharArray(), c => c - 'a' + 1));

        Console.SetOut(new System.IO.StreamWriter(Console.OpenStandardOutput())
        {
            AutoFlush = false
        });
        foreach (var(l, r) in qs)
        {
            Console.WriteLine(cs.Sum(l - 1, r));
        }
        Console.Out.Flush();
    }