# Help me in solving DISHLIFE problem

### My issue

plz debug this code

### My code

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

int main() {
int t;
cin>>t;

while(t--){
int n,k;
cin>>n>>k;
unordered_map<int,int>mp;

for(int i=0;i<n;i++){
int a;
cin>>a;
mp[a]++;
while(a--){
int b;
cin>>b;
mp[b]++;
}
if(i!=n-1){
if(mp.find(k)!=mp.end()){ cout<<"some\n";
break;
}

}
else {
if(i==n-1){
if(mp.find(k)!=mp.end()){
cout<<"all\n";
}
else {
}

}
}

}
return 0;
}

``````

Problem Link: DISHLIFE Problem - CodeChef

@deepakjdh31
Your logic is not right dude .U have to search for all 1-k number not only k.
Second U have to rethink over the logic when u will get some as the answer.
Hint :- They need not to be contiguous to get some. We can also get some with the help of the island numbered 1,2,5,6 etc.

include <bits/stdc++.h>
define ll long long int
using namespace std;

int main() {
int t;
cin>>t;

``````while(t--){
ll n,x;
cin>>n>>x;
unordered_map<ll,ll>ump;

for(ll i=0;i<n;i++)
{
ll a;
cin>>a;
ump[a]++;
while(a--){
ll b;
cin>>b;
ump[b]++;
}
ll k=0;
k=ump.size();
if(i!=n-1){
if(k==x){
cout<<"some\n";
break;
}
else{
continue;
}

}
else if(i==n-1){
if(k==x){
cout<<"all\n";  }
else {
}
}

}
return 0;
``````

}
// is this logic regarding right dude?, i am stuck here

You should first take all the inputs you have done the calculation part while still inputting the given values and you are also using break statement which will cause the next input to be wrong. You should first take the input and store in map however you want and after that iterate through the map to perform your logic.

@deepakjdh31
This is my code for reference hope u will get the mistake now.
Just look deep into the logic for printing “some”.

``````#include <bits/stdc++.h>
#define ll long int
using namespace std;

int main() {
int t;
cin>>t;
while(t--){
ll n,k;
cin>>n>>k;
ll flag=0;
map<ll,ll> mp;
vector<vector<int>> v;
for(int i=0;i<n;i++)
{
ll p;
cin>>p;
vector<int> val(p);
for(int j=0;j<p;j++)
{
cin>>val[j];
mp[val[j]]++;
}
v.push_back(val);
}
if(mp.size()!=k)
{
}
else
{
for(int i=0;i<v.size();i++)
{
int ch=0;
for(int j=0;j<v[i].size();j++)
{
if(mp[v[i][j]]==1)
{
ch=1;
}
}
if(!ch)
{
flag=1;
}
}
if(flag)
cout<<"some";
else
cout<<"all";
}
cout<<endl;
}
return 0;
}
``````

This code is correct it passes all the test cases. Is there still some other verdict at your end?

for(int j=0;j<v[i].size();j++)
{
if(mp[v[i][j]]==1)
{
ch=1;
}
What we are doing in this loop ??