Keyboard Queries
Time limit1sMemory limit1024 MB
Given palindrome facts about substrings of S, decide whether two substrings must be equal, cannot be equal, or remain undetermined.
- Level
Hard8 of 10
- Topics
- Union-find, String matching, String
- Solved
- No attempts yet
Problem
Katrín and her friends are university students who attend a seminar every week. At the start of each seminar, the professor splits the students into groups at random. Katrín and her friends dislike random groups. They want to form a group together so they can chat and avoid getting to know the other students.
The professor keeps a secret string of length on their computer. This string seeds the random group generation. To generate groups, a program named manager runs on a substring of . Sometimes the professor mistypes and writes manacher instead, which means the substring is a palindrome. Can Katrín use this information to predict the group division?
The string has characters over an unknown alphabet. You are given queries of two types.
1 l r: The substring of from index through index is a palindrome.2 a b x y: Determine whether the substring from index through equals the substring from index through , given the information from the previous queries.
Input
The first line contains two integers and (, ), the length of the string and the number of queries. Each of the following lines starts with 1 or 2, the query type.
For type 1, two integers and follow (). For type 2, four integers , , , follow (, ).
Output
For each query of the second type, print "Equal" if the two substrings must be equal, "Not equal" if they cannot be equal, and "Unknown" if both are still possible given the information so far.