Editorial for Подобни масиви


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.

Submitting an official solution before solving the problem yourself is a bannable offence.
by: maya

Тестовете можете да видите тук.

Примерно решение на C++:

#include<iostream>
using namespace std;

long long i,n,x,a[1001],y,m,b[1001],br,br1;
int main()
{
    cin>>n;
    for(i=1; i<=n; i++)
    {
        cin>>x;
        a[x]++;
    }
    cin>>m;
    for(i=1; i<=m; i++)
    {
        cin>>y;
        b[y]++;
    }
    for(i=1; i<=1000; i++)
    {
        if(a[i]!=0) br++;
    }

    for(i=1; i<=1000; i++)
    {
        if(a[i]!=0 && b[i]!=0) br1++;
    }

    if(br!=br1)
    {
        for(i=1; i<=1000; i++)
        {
            if(a[i]!=0 && b[i]==0) cout<<i<<" ";
        }
    }
    else cout<<br1<<endl;

    return 0;
}

Comments

There are no comments at the moment.