#P12009. 【MX-X10-T5】[LSOT-4] Masuko or Haru?
【MX-X10-T5】[LSOT-4] Masuko or Haru?
Description
You are given binary strings of length .
An interval pair is defined as a pair where .
An interval set is a collection of interval pairs.
For a binary string , a transformation with respect to an interval set involves selecting any interval pair , , where denotes bitwise XOR.
Two binary strings and are equivalent under an interval set if can be transformed into after any number of transformations with respect to .
Initially, .
There are operations, each being either an insertion or a query:
- Insertion: Add a given interval pair to .
- Query: Given and , determine whether the -th and -th binary strings are equivalent under the current .
Input Format
- The first line contains three integers , , .
- The second line contains a binary string of length . The -th to -th characters represent the -th binary string.
- The next lines each start with an integer :
- If , it is an insertion operation followed by two integers .
- If , it is a query operation followed by two integers .
Output Format
For each query, output a single line: Masuko if the two strings are equivalent, otherwise Haru.
2 5 5
1001111001
2 1 2
1 2 3
2 1 2
1 3 4
2 1 2
Haru
Haru
Masuko
10 10 20
1110001000101011110100110000110111001111111110111101001111011111011101000000000111110100010000100110
2 2 1
2 9 6
2 6 10
2 1 1
2 3 2
1 7 9
2 10 10
2 10 4
1 1 7
1 8 8
1 2 3
1 2 7
2 1 9
2 6 1
1 1 3
2 10 7
1 2 4
2 9 1
1 3 7
1 1 5
Haru
Haru
Haru
Masuko
Haru
Masuko
Haru
Haru
Haru
Haru
Haru
Hint
Sample Explanation #1
Initial binary strings are:
10011,
11001.
- First query: is empty. The strings are obviously different.
- Second query: . The first string can only become
10011or11111, which cannot match the second string. - Third query: . Applying transformations in sequence converts the first string to the second string. Hence equivalent.
Data Range
This problem uses subtasks with bundled testing.
- Subtask 1 (17 pts): , .
- Subtask 2 (14 pts): .
- Subtask 3 (16 pts): .
- Subtask 4 (13 pts): Insertions do not exceed 5000.
- Subtask 5 (21 pts): All insertions occur before queries.
- Subtask 6 (19 pts): No additional constraints.
For all data: , , , , .
Translation by DeepSeek R1
京公网安备 11011102002149号