A9342 | Semifinals
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Two semifinals have just been in the running tournament. Each semifinal had $n$ participants. There are $n$ participants advancing to the finals, they are chosen as follows: from each semifinal, we choose $k$ people ( $0<=2k<=n$ ) who showed the best result in their semifinals and all other places in the finals go to the people who haven't ranked in the top $k$ in their semifinal but got to the $n-2k$ of the best among the others.
The tournament organizers hasn't yet determined the $k$ value, so the participants want to know who else has any chance to get to the finals and who can go home.
The tournament organizers hasn't yet determined the $k$ value, so the participants want to know who else has any chance to get to the finals and who can go home.
输入格式
The first line contains a single integer $n$ ( $1<=n<=10^{5}$ ) — the number of participants in each semifinal.
Each of the next $n$ lines contains two integers $a_{i}$ and $b_{i}$ ( $1<=a_{i},b_{i}<=10^{9}$ ) — the results of the $i$ -th participant (the number of milliseconds he needs to cover the semifinals distance) of the first and second semifinals, correspondingly. All results are distinct. Sequences $a_{1}$ , $a_{2}$ , ..., $a_{n}$ and $b_{1}$ , $b_{2}$ , ..., $b_{n}$ are sorted in ascending order, i.e. in the order the participants finished in the corresponding semifinal.
Each of the next $n$ lines contains two integers $a_{i}$ and $b_{i}$ ( $1<=a_{i},b_{i}<=10^{9}$ ) — the results of the $i$ -th participant (the number of milliseconds he needs to cover the semifinals distance) of the first and second semifinals, correspondingly. All results are distinct. Sequences $a_{1}$ , $a_{2}$ , ..., $a_{n}$ and $b_{1}$ , $b_{2}$ , ..., $b_{n}$ are sorted in ascending order, i.e. in the order the participants finished in the corresponding semifinal.
输出格式
Print two strings consisting of $n$ characters, each equals either "0" or "1". The first line should correspond to the participants of the first semifinal, the second line should correspond to the participants of the second semifinal. The $i$ -th character in the $j$ -th line should equal "1" if the $i$ -th participant of the $j$ -th semifinal has any chances to advance to the finals, otherwise it should equal a "0".
输入输出样例
输入 #1
4 9840 9920 9860 9980 9930 10020 10040 10090
输出 #1
1110 1100
输入 #2
4 9900 9850 9940 9930 10000 10020 10060 10110
输出 #2
1100 1100
Consider the first sample. Each semifinal has 4 participants. The results of the first semifinal are 9840, 9860, 9930, 10040. The results of the second semifinal are 9920, 9980, 10020, 10090.
- If $k=0$ , the finalists are determined by the time only, so players 9840, 9860, 9920 and 9930 advance to the finals.
- If $k=1$ , the winners from both semifinals move to the finals (with results 9840 and 9920), and the other places are determined by the time (these places go to the sportsmen who run the distance in 9860 and 9930 milliseconds).
- If $k=2$ , then first and second places advance from each seminfial, these are participants with results 9840, 9860, 9920 and 9980 milliseconds.
- If $k=0$ , the finalists are determined by the time only, so players 9840, 9860, 9920 and 9930 advance to the finals.
- If $k=1$ , the winners from both semifinals move to the finals (with results 9840 and 9920), and the other places are determined by the time (these places go to the sportsmen who run the distance in 9860 and 9930 milliseconds).
- If $k=2$ , then first and second places advance from each seminfial, these are participants with results 9840, 9860, 9920 and 9980 milliseconds.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted