Пример #1
0
        public int LCP(int l1, int r1, RollingHash target, int l2, int r2)
        {
            int len = Math.Min(r1 - l1, r2 - l2);
            int ok  = -1;
            int ng  = len + 1;

            while (ng - ok > 1)
            {
                int mid = (ok + ng) / 2;
                if (GetHash(l1, l1 + mid) == target.GetHash(l2, l2 + mid))
                {
                    ok = mid;
                }
                else
                {
                    ng = mid;
                }
            }

            return(ok);
        }
Пример #2
0
 public int LCP(Range range1, RollingHash target, Range range2)
 => LCP(range1.Start.Value, range1.End.Value, target, range2.Start.Value, range2.End.Value);
Пример #3
0
 public int LongestCommonPrefix(int l1, int r1, RollingHash target, int l2, int r2)
 => LCP(l1, r1, target, l2, r2);
Пример #4
0
 public int LongestCommonPrefix(Range range1, RollingHash target, Range range2)
 => LCP(range1.Start.Value, range1.End.Value, target, range2.Start.Value, range2.End.Value);