示例#1
0
        public static SuffixArray Create <T>(T[] str)
        {
            var sa  = StringLib.SuffixArray(str);
            var lcp = StringLib.LCPArray(str, sa);

            return(new SuffixArray(sa, lcp));
        }
        public void Solve(ConsoleReader cr, ConsoleWriter cw)
        {
            string s      = cr;
            var    sa     = StringLib.SuffixArray(s);
            var    answer = 1L * s.Length * (s.Length + 1) / 2;

            foreach (var x in StringLib.LCPArray(s, sa))
            {
                answer -= x;
            }
            cw.WriteLine(answer);
        }
    public static long Calc(int n)
    {
        long ans = 0;

        n >>= 4;
        var s = new long[n];

        for (int i = 0; i < s.Length; i++)
        {
            s[i] = long.MaxValue + (i % 2 == 0 ? i : -i);
        }
        var sa  = StringLib.SuffixArray(s);
        var lcp = StringLib.LCPArray(s, sa);

        ans = lcp[0];
        return(ans);
    }
    public static long Calc(int n)
    {
        long ans = 0;

        n >>= 3;
        var c = new char[n];

        for (int i = 0; i < c.Length; i++)
        {
            c[i] = (char)(i % 127);
        }
        var s   = new string(c);
        var sa  = StringLib.SuffixArray(s);
        var lcp = StringLib.LCPArray(s, sa);

        ans = lcp[0];
        return(ans);
    }