HackerEarth Distinct Count problem solution YASH PAL, 31 July 2024 In this HackerEarth Distinct Count problem solution we have given an array A of N integers, classify it as being Good Bad, or Average. It is called Good, if it contains exactly X distinct integers, Bad if it contains less than X distinct integers, and Average if it contains more than X distinct integers. HackerEarth Distinct Count problem solution. #include <bits/stdc++.h>using namespace std;int main () { int tc; scanf("%d",&tc); while (tc--) { int n, k; scanf("%d%d",&n,&k); set < int > s; int temp; for (int i=0; i<n; i++) { scanf("%d",&temp); s.insert(temp); } if (s.size()<k) { printf("Bad husbandn"); } if (s.size()==k) { printf("Perfect husbandn"); } if (s.size()>k) { printf("Lame husbandn"); } } return 0;} Second solution #include<bits/stdc++.h>using namespace std;#define ll long long int#define vi vector<int>#define vl vector<ll>#define pii pair<int,int>#define pil pair<int, ll>#define pll pair<ll, ll>#define pli pair<ll, int>#define pb(v, a) v.push_back(a)#define mp(a, b) make_pair(a, b)#define MOD 1000000007#define rep(i, a, b) for(i=a; i<=b; ++i)#define rrep(i, a, b) for(i=a; i>=b; --i)#define si(a) scanf("%d", &a)#define sl(a) scanf("%lld", &a)#define pi(a) printf("%d", a)#define pl(a) printf("%lld", a)#define pn printf("n")ll pow_mod(ll a, ll b){ ll res = 1; while(b) { if(b & 1) res = (res * a) % MOD; a = (a * a) % MOD; b >>= 1; } return res;}set<int> s;int main(){ int t, i, n, x, j, tmp; si(t); assert(t >= 1 && t <= 50); rep(i, 1, t) { s.clear(); si(n); si(x); assert(n >= 1 && n <= 13000); assert(x >= 1 && x <= 13000); rep(j, 1, n) { si(tmp); assert(tmp >= 1 && tmp <= 1000000000); s.insert(tmp); } if(s.size() < x) printf("Bad husbandn"); else if(s.size() > x) printf("Lame husbandn"); else printf("Perfect husbandn"); } return 0;} coding problems