Linear Hash gives WA , Double Hash gives TLE How can I solve ? [SSTORY] [SOLVED]

Question : “https://www.codechef.com/problems/SSTORY

Linear Hash : “https://www.codechef.com/viewsolution/36879132” [WA]

Double Hash : “https://www.codechef.com/viewsolution/36879441” [TLE]

Help @everule1 @ssjgz @galencolin @ay2306

Solved using unordered set of pair after 8 penalities.

https://www.techiedelight.com/use-pair-key-std-unordered_set-cpp/

My solution : “https://www.codechef.com/viewsolution/36879695