My issue
My code is worked successfully but it seems test cases for this problem are not proper
for the below input ideally answer should be “some” as we can skip the 2nd island but test case passes for “all”.
Can some one help me to confirm whether my understanding is correct or not?
Input:
1
3 5
3 1 2 3
3 1 3 4
2 4 5
My code
# cook your dish here
for _ in range(int(input())):
n, k = map(int,input().split())
a = []
for _ in range(n):
t = list(map(int,input().split()))
a.append(t)
a = sorted(a,reverse=True)
d = {i:0 for i in range(1,k+1)}
vc = 0
some = False
for row in a:
visited = False
for ind in range(1,row[0]+1):
if d[row[ind]] == 0:
vc += 1
visited = True
d[row[ind]] = 1
if not visited:
some = True
if vc <k:
print("sad")
elif some:
print("some")
else:
print("all")
Problem Link: Dish Of Life Practice Coding Problem - CodeChef