zoukankan      html  css  js  c++  java
  • codeforces 519B. A and B and Compilation Errors

    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
    5
    1 5 8 123 7
    123 7 5 1
    5 1 7
    output
    8
    123
    input
    6
    1 4 3 3 5 7
    3 7 5 4 3
    4 3 7 5
    output
    1
    3
    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.

    第一行输入n个数,第二行输入n-1个数,检查哪个数消失了,举个例子,把第一行的数和第二行的数分别排一下序,然后从前往后(n-1个数里面)找一对ai!=bi的数,输出ai,

     1 #include<iostream>
     2 #include<algorithm>
     3 #include<cstring>
     4 #include<iomanip>
     5 #include<cctype>
     6 #include<string>
     7 #include<cmath>
     8 #include<cstdio>
     9 #include<cstdlib>
    10 #define LL long long
    11 #define PF(x) ((x)*(x))
    12 #define LF(x) ((x)*PF(x))
    13 
    14 using namespace std;
    15 const int INF=1<<31-1;
    16 const int max9=1e9;
    17 const int max6=1e6;
    18 const int max3=1e3;
    19 
    20 int gcd(int a,int b)
    21 {
    22     return b==0?a:gcd(b,a%b);
    23 }
    24 int t[max6];
    25 int s[max6];
    26 int x[max6];
    27 void solve1(int w)
    28 {
    29     for(int i=0;i<w;i++)
    30     {
    31         if(t[i]!=s[i])
    32         {
    33             cout << t[i] << endl;
    34             return;
    35         }
    36     }
    37     cout << t[w] << endl;
    38     return;
    39 }
    40 void solve2(int w)
    41 {
    42     for(int i=0;i<w;i++)
    43     {
    44         if(x[i]!=s[i])
    45         {
    46             cout << s[i] << endl;
    47             return;
    48         }
    49     }
    50     cout << s[w] << endl;
    51     return;
    52 }
    53 int main()
    54 {
    55     int n;
    56     while(cin >> n)
    57     {
    58         for(int i=0;i<n;i++)   cin >> t[i];
    59         sort(t,t+n);
    60         for(int i=0;i<n-1;i++) cin >> s[i];
    61         sort(s,s+n-1);
    62         for(int i=0;i<n-2;i++) cin >> x[i];
    63         sort(x,x+n-2);
    64         solve1(n-1);
    65         solve2(n-2);
    66     }
    67     return 0;
    68 }
    View Code
  • 相关阅读:
    Linux上将文件夹复制到指令目录
    将PC版网页转为手机端自适应网页
    WCF初探-18:WCF数据协定之KnownType
    WCF初探-17:WCF数据协定之等效性
    WCF初探-16:WCF数据协定之基础知识
    WCF初探-15:WCF操作协定
    2018数学二21题解法分析
    柯西不等式:简单常考形式
    等价、合同、相似、正交变换;二次型,正定,惯性指数
    高数狄利克雷收敛条件(傅里叶)
  • 原文地址:https://www.cnblogs.com/I-love-HLD/p/4306579.html
Copyright © 2011-2022 走看看