C - Semifinals

Description

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.

Input

The first line contains a single integer n (1 ≤ n ≤ 105) — the number of participants in each semifinal.

Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 109) — 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 a1, a2, ..., an and b1, b2, ..., bn are sorted in ascending order, i.e. in the order the participants finished in the corresponding semifinal.

Output

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".

Sample Input

Input

4
9840 9920
9860 9980
9930 10020
10040 10090

Output

1110
1100

Input

4
9900 9850
9940 9930
10000 10020
10060 10110

Output

1100
1100
 
分析:这道题还是主要地读题,学好英语还是很重要的。大意:两个半决赛刚刚跑步比赛。每个半决赛都有n个参与者。有n个参与者进军总决赛,他们选择如下:从每个半决赛,我们选择k(0≤2 k≤n)人显示最好的结果在半决赛和决赛中所有其他地方去的人还没有排名在前k的半决赛,但得n - 2 k中最好的。    比赛组织者尚未确定k值,所以参与者想知道还有谁有机会进入决赛,谁能回家。
参考代码如下:
#include
#include
int a[1000010],b[1000010];
void ans(int k,int n)
{
    for(int i=0;i<=k;i++)
    printf("1");
    for(int i=k+1;ib)?a:b;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i

更多做题心得的详情请查看(记得关注哦)https://mp.weixin.qq.com/s?__biz=MzIyOTM4MDMxNw==&mid=2247483798&idx=1&sn=d4fbd34e50ce4efda39d7710d2dc5dc9&chksm=e842d824df3551320d7f1ed85286b2616aec419f7a852cc5c9c9f270beb237b5e6ca83166162&token=1630951018&lang=zh_CN#rd

你可能感兴趣的:(oj做题--心得与体会)