Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n, a, b = list(map(int, input().split()))
- s = input()
- ans = 0
- while len(s) > 0:
- l = 0
- r = len(s) // 2
- m = 0
- ok = 0
- while l <= r:
- m = (l + r) // 2
- if s[len(s) - m::] in s[:len(s) - m]:
- ok = m
- l = m + 1
- else:
- r = m - 1
- if ok == 0:
- ans += a
- s = s[:-1]
- else:
- ans += min(ok * a, b)
- s = s[:-ok]
- print(ans)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement