private long[] Solve(string text, long n, string[] patterns) { List <long> result = new List <long>(); text = text + '$'; long[] suffixArray = SuffixArray.BuildSuffixArray(text); bool[] isAdded = new bool[suffixArray.Length]; foreach (var pattern in patterns) { int minIdx = LeftBS(suffixArray, pattern, text); int maxIdx = RightBS(suffixArray, pattern, text); if (minIdx == -1 || maxIdx == -1) { continue; } for (int i = minIdx; i <= maxIdx; i++) { if (!isAdded[i]) { result.Add(suffixArray[i]); isAdded[i] = true; } } } if (!result.Any()) { result.Add(-1); } return(result.ToArray()); }
public long[] Solve(string text, long n, string[] patterns) { List <long> results = new List <long>(); SuffixArray s = new SuffixArray(text + '$'); var suffixarray = s.ConstructSuffixArray(); foreach (var pattern in patterns) { var res = s.Search(pattern); foreach (var index in res) { if (!results.Contains(index)) { results.Add(index); } } } if (!results.Any()) { return new long[] { -1 } } ; return(results.ToArray()); } }
private long[] Solve(string text, long n, string[] patterns) { text += '$'; var suffixArray = new SuffixArray().BuildSuffixArray(text); var result = new List <long>(); foreach (var pattern in patterns) { PatternMatching(text, pattern, suffixArray, ref result); } if (result.Count == 0) { result.Add(-1); } return(result.Distinct().ToArray()); }
private long[] Solve(string text) { return(SuffixArray.BuildSuffixArray(text)); }
private long[] Solve(string text) { var suffixArray = new SuffixArray(text); return(suffixArray.ConstructSuffixArray().Select(x => (long)x).ToArray()); }
private long[] Solve(string text) { var suffixArray = new SuffixArray(); return(suffixArray.BuildSuffixArray(text)); }
private long[] Solve(string text) { SuffixArray mySA = new SuffixArray(text); return(mySA.BuildSuffixArray()); }