A1386 | [COCI-2020-2021-contest3]#5 Vlak
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Nina and Emilija are playing a game on a piece of paper. Initially, the paper is empty.
In one move a player appends a letter to the end of the word that is currently written on the paper. They alternate turns, and Nina plays first.
Players must choose the letters in such a way that the following condition is met: the word that is written after the player’s move must be a prefix of some word in that players favourite song. If the player can’t make a move, she loses.
If both players play optimally, determine who wins.
In one move a player appends a letter to the end of the word that is currently written on the paper. They alternate turns, and Nina plays first.
Players must choose the letters in such a way that the following condition is met: the word that is written after the player’s move must be a prefix of some word in that players favourite song. If the player can’t make a move, she loses.
If both players play optimally, determine who wins.
输入格式
The first line contains a positive integer n, the number of words in Nina’s favourite song.
Each of the following n lines contains a word from Nina’s favourite song.
The following line contains a positive integer m, the number of words in Emilija’s favourite song.
Each of the following m lines contains a word from Emilija’s favourite song.
Words in input contain only lowercase letters, and the sum of the lengths of all words is at most 200 00
0.
Each of the following n lines contains a word from Nina’s favourite song.
The following line contains a positive integer m, the number of words in Emilija’s favourite song.
Each of the following m lines contains a word from Emilija’s favourite song.
Words in input contain only lowercase letters, and the sum of the lengths of all words is at most 200 00
0.
输出格式
Output Nina or Emilija, the name of the winner.
输入输出样例
输入 #1
2 aaa bbb 3 aab aba bbb
输出 #1
Nina
输入 #2
2 acg beh 2 adi bfj
输出 #2
Emilija
In test cases worth 40 points the sum of the lengths of the words will be at most 2000.
Clarification of the first example:
If Nina first writes b, Emilija must write b, and then Nina can write b. The current word is bbb, and
Emilija can’t make a move, so Nina wins.
If Nina would first write a, Emilija could write b. The word would be ab, and Nina wouldn’t be able to
make a move, and she would lose.
Clarification of the first example:
If Nina first writes b, Emilija must write b, and then Nina can write b. The current word is bbb, and
Emilija can’t make a move, so Nina wins.
If Nina would first write a, Emilija could write b. The word would be ab, and Nina wouldn’t be able to
make a move, and she would lose.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted