A and B and Compilation Errors——找出消失的数字

来源:互联网 发布:袁隆平 诺贝尔奖 知乎 编辑:程序博客网 时间:2024/04/30 02:13
B. A and B and Compilation Errors
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

A and B are preparing themselves for programming contests.

B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.

Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake.

However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared — the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change.

Can you help B find out exactly what two errors he corrected?

Input

The first line of the input contains integer n (3 ≤ n ≤ 105) — the initial number of compilation errors.

The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the errors the compiler displayed for the first time.

The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 — the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one.

The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 — the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one.

Output

Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively.

Sample test(s)
input
51 5 8 123 7123 7 5 15 1 7
output
8123
input
61 4 3 3 5 73 7 5 4 34 3 7 5
output
13
Note

In the first test sample B first corrects the error number 8, then the error number 123.

In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step.

大水题,只恨自己当初读懂了题意没有去做。。。。。。

第一行给出数字的个数,第二行给出原始数字,第三行给出处理一个数字之后剩下的数字,第四行给出处理两个数字之后剩下的数字,找出这两次分别处理的数字。

其实题目很简单,将给出的三行数据分别从小到大排序,因为有先后顺序,那么当找到一个不在原来序列中的数据时,就肯定是这个数据。具体看代码:

#include <iostream>#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;__int64 sz1[100009],sz2[100009];int main(){    int n,i,j,k;    while(~scanf("%d",&n))    {        for(i = 0; i < n; i++)//输入第一行数据        {            scanf("%I64d",&sz1[i]);        }        for(i = 0; i < n-1; i++)//输入第二行数据        {            scanf("%I64d",&sz2[i]);        }        sort(sz1,sz1+n);//对这两组数据分别排序        sort(sz2,sz2+n-1);        k = 0;        for(i = 0,j = 0; i < n; i++,j++)//从头到尾依次遍历        {            if(sz1[j] != sz2[i])//当发现两数据不相同时那么数据个数多的序列所在的那个数据肯定是被删除了            {                k = sz1[j];//这样就是找到了第一次修改的数据,直接输出即可                break;            }        }        printf("%d\n",k);        memset(sz1,0,sizeof(sz1));        for(i = 0; i < n-2; i++)        {            scanf("%I64d",&sz1[i]);        }        sort(sz1,sz1+n-2);        for(i = 0,j = 0; j < n-1; j++,i++)        {            if(sz1[i] != sz2[j])            {                k = sz2[j];                break;            }        }        printf("%d\n",k);    }    return 0;}


0 0