I tried the Min Max string using Hashing . I first calculated the hash value of all the Initial string. Then I created a map . Then I compared the hash value of the last character of each string with every other string and if it didn’t matched with anyone inserted it in the map. Then I went to the queries , if query is of 1st type, I took the value of the hash of the last character of the given string and computed its hash after ammending it with given letter.Then I erased the string from the map which is used to create the new string as old string would be a proper prefix of new one. Then I compared the hash value of new string with every other string present in the map whose size is greater than new string.
If query is of 2nd or 3rd type I simple printed the first and last value.
It is showing SIGSEGV . Please Help . Your help will be really appreciated.
Link to My solution https://www.codechef.com/viewsolution/36699572
Precisely what it says: on line 22, you are attempting to access the element at index 200001 in array with only 200001 values (array indexing is 0-relative, remember!)
Your poweri array is too small. Have at least size 4*10^5, because the maximum size of string can be 2*10^5, and then there are 2*10^5 queries after that.
I have found a random test case on which it fails , but i am not able to understand why it fails more accurately it is not taking the x for the 4th query can someone please explain why. Here is the random testcase I generated.
1
3
abcdefaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
abcaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
xyz
6
1 2 d
2
3
1 3 c
2
3
can you explain this one as well and also tell which IDE you use .
you can also explain with the below test case as well as (any one would be sufficient) it too fails on same condition.
1
3
abcdefa
abca
xyz
6
1 2 d
2
3
1 3 c
2
3