# SAMEELEMENT - EDITORIAL

Practice
Contest

Author: Pratik Suryawanshi

Editorialist: Pratik Suryawanshi

Easy

2D-array

# PROBLEM:

You have given two different arrays a1,a2,a3,…….,aN. and x1,x2,x3,……,xM. of
size N and M respectively, We have to check whether the given arrays are EPIC or not,

the condition for EPIC arrays is the number of matching/same elements of both the arrays
are exactly should be equal to the N/2 . so check whether the arrays are epic or not

# QUICK EXPLANATION:

We have to count same element of second array in first array

# EXPLANATION:

by taking 2D array , count number of same element in both the arrays .
if count == (number of elements in first array)/2 : then print YES
else print NO

# SOLUTIONS:

Setter's Solution

indent whole code by 4 spaces

#include<bits/stdc++.h>
using namespace std;

#define FILE freopen(“input.txt”,“r”,stdin); freopen(“output.txt”,“w”, stdout);
#define GetSetBolt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define LL long long int
#define LD long double

#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define FF first
#define SS second
#define PB push_back
#define PF push_front
#define PPB pop_back
#define PPF pop_front
#define Endl endl

#define in(arr,n) for(int i=0;i<n;i++) cin>>arr[i];
#define in2(arr,n,m) for(int i=0;i<n;i++){ for(int j=0;j<m;j++) cin>>arr[i][j];}
#define dis(arr,n) for(int i=0;i<n;i++) cout<<arr[i]<<" “; cout<<endl;
#define dis2(arr,n,m) for(int ii=0;ii<n;ii++){for(int j=0;j<m;j++)cout<<arr[ii][j]<<” ";cout<<endl;}
#define TC() int t=0;cin>>t; while(t–)

#define For(n) for(LL i=0;i<n;i++)
#define For0(x,z) for(LL x=0;x<z;x++)
#define Forx(x,z) for(x;x<z;x++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()

#define toLower(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define toUpperr(s) transform(s.begin(),s.end(),s.begin(),::toupper)

#define sortVD(v) sort(v.begin(), v.end(), greater());
#define sortA(arr) sort(arr,arr+n);
#define sortV(v) sort(v.begin(),v.end());

#define mem0(X) memset((X), 0, sizeof((X)))
#define memx(X,x) memset((X), x, sizeof((X)))
#define setbits(X) __builtin_popcountll(X)
#define precise(X) cout<<fixed << setprecision(X);

// #ifndef ONLINE_JUDGE
// cerr<<"\ntime taken : “<<(float)clock()/CLOCKS_PER_SEC<<” secs"<<"\n";
// #endif
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<double,double> PDD;
typedef pair<string, string> PSS;
typedef pair<string, LL> PSL;

typedef vector VI;
typedef vector VL;
typedef vector VD;
typedef vector VS;
typedef vector VVI;
typedef vector VVL;
typedef vector VVS;
typedef vector VPII;
typedef vector VPLL;
typedef vector VPSS;
typedef vector VPSL;

typedef map<int,int> MII;
typedef map<LL,LL> MLL;
typedef map<char,LL> MCL;
typedef map<char,int> MCI;
typedef map<char,LL> MCL;
typedef map<string,string> MSS;
typedef map<string,int> MSI;
typedef map<string,LL> MSL;

typedef unordered_map<int,int> UMII;
typedef unordered_map<LL,LL> UMLL;
typedef unordered_map<char,LL> UMCL;
typedef unordered_map<char,int> UMCI;
typedef unordered_map<char,LL> UMCL;
typedef unordered_map<string,string> UMSS;
typedef unordered_map<string,int> UMSI;
typedef unordered_map<string,LL> UMSL;

int main()
{
// code here

int t;
cin >> t;
while(t–)
{
int n,m;
cin >> n>> m;
int cnt=0;
int arr1[n];
int arr2[m];
for(int i=0;i<n;i++)
{
cin >> arr1[i];
}
for(int j=0;j<m;j++)
{
cin >> arr2[j];
}
sort(arr1,arr1+n);
sort(arr2,arr2+m);

``````for(int i=0, j=0; i<n && j<m;)
{
if(arr1[i] == arr2[j])
{
i++;
j++;
cnt++;
}
else if(arr1[i] < arr2[j])
{
i++;
}
else
j++;

}
if(cnt == (n/2) )
{
cout << "YES" << "\n";
}
else
cout << "NO" << "\n";
``````

}

``````return 0;
``````

}