A8874 | Weird Game
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Yaroslav, Andrey and Roman can play cubes for hours and hours. But the game is for three, so when Roman doesn't show up, Yaroslav and Andrey play another game.
Roman leaves a word for each of them. Each word consists of $2·n$ binary characters "0" or "1". After that the players start moving in turns. Yaroslav moves first. During a move, a player must choose an integer from 1 to $2·n$ , which hasn't been chosen by anybody up to that moment. Then the player takes a piece of paper and writes out the corresponding character from his string.
Let's represent Yaroslav's word as $s=s_{1}s_{2}...\ s_{2n}$ . Similarly, let's represent Andrey's word as $t=t_{1}t_{2}...\ t_{2n}$ . Then, if Yaroslav choose number $k$ during his move, then he is going to write out character $s_{k}$ on the piece of paper. Similarly, if Andrey choose number $r$ during his move, then he is going to write out character $t_{r}$ on the piece of paper.
The game finishes when no player can make a move. After the game is over, Yaroslav makes some integer from the characters written on his piece of paper (Yaroslav can arrange these characters as he wants). Andrey does the same. The resulting numbers can contain leading zeroes. The person with the largest number wins. If the numbers are equal, the game ends with a draw.
You are given two strings $s$ and $t$ . Determine the outcome of the game provided that Yaroslav and Andrey play optimally well.
Roman leaves a word for each of them. Each word consists of $2·n$ binary characters "0" or "1". After that the players start moving in turns. Yaroslav moves first. During a move, a player must choose an integer from 1 to $2·n$ , which hasn't been chosen by anybody up to that moment. Then the player takes a piece of paper and writes out the corresponding character from his string.
Let's represent Yaroslav's word as $s=s_{1}s_{2}...\ s_{2n}$ . Similarly, let's represent Andrey's word as $t=t_{1}t_{2}...\ t_{2n}$ . Then, if Yaroslav choose number $k$ during his move, then he is going to write out character $s_{k}$ on the piece of paper. Similarly, if Andrey choose number $r$ during his move, then he is going to write out character $t_{r}$ on the piece of paper.
The game finishes when no player can make a move. After the game is over, Yaroslav makes some integer from the characters written on his piece of paper (Yaroslav can arrange these characters as he wants). Andrey does the same. The resulting numbers can contain leading zeroes. The person with the largest number wins. If the numbers are equal, the game ends with a draw.
You are given two strings $s$ and $t$ . Determine the outcome of the game provided that Yaroslav and Andrey play optimally well.
输入格式
The first line contains integer $n$ ( $1<=n<=10^{6}$ ). The second line contains string $s$ — Yaroslav's word. The third line contains string $t$ — Andrey's word.
It is guaranteed that both words consist of $2·n$ characters "0" and "1".
It is guaranteed that both words consist of $2·n$ characters "0" and "1".
输出格式
Print "First", if both players play optimally well and Yaroslav wins. If Andrey wins, print "Second" and if the game ends with a draw, print "Draw". Print the words without the quotes.
输入输出样例
输入 #1
2 0111 0001
输出 #1
First
输入 #2
3 110110 001001
输出 #2
First
输入 #3
3 111000 000111
输出 #3
Draw
输入 #4
4 01010110 00101101
输出 #4
First
输入 #5
4 01100000 10010011
输出 #5
Second
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted