P9738 [COCI 2022/2023 #2] Prijateljice
Description
Leona and Zoe have some words. They plan to play a game with these words:
In each round, the two players take turns saying a word. The word must satisfy the following requirements:
It is lexicographically greater than the previous word, and its first letter must be the same as the first letter of the previous word, or exactly the next letter in the alphabet after the first letter of the previous word.
Leona speaks first, and he will choose the lexicographically smallest word to say. When it is someone’s turn and they cannot say a word, they lose.
While playing this game, both players use optimal strategies, that is, they always choose the lexicographically smallest word among all valid choices.
Now they want to know who will win.
Input Format
The first line contains two integers $n$ and $m$ ($1 \le n,m \le 10^5$).
The next $n$ lines each contain a string, representing the words owned by Leona.
The next $m$ lines each contain a string, representing the words owned by Zoe.
All input words are lowercase letters and are pairwise distinct. Their total length does not exceed $10^6$. They are given in lexicographical order.
Output Format
Output one line containing a string, either $\texttt{Leona}$ or $\texttt{Zoe}$, indicating the winner.
Explanation/Hint
|$\text{Subtask}$|Score|Special Property|
|:-:|:-:|:-:|
|$1$|$20$|$n,m\le100$, each word has length at most $10$|
|$2$|$30$|$n,m\le1000$|
|$3$|$60$|None|
**The full score for this problem is $110$ points.**
Translated by ChatGPT 5