-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjune5.cpp
More file actions
72 lines (72 loc) · 672 Bytes
/
june5.cpp
File metadata and controls
72 lines (72 loc) · 672 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include<iostream>
using namespace std;
struct name
{
int len;
int b[250];
};
bool count(name c,name d,int k)
{
int l1=c.len,l2=d.len;
int i=0,j=0,m=0;
while(i<l1&&j<l2)
{
if(c.b[i]<d.b[j])
{
m++;
i++;
}
else if(c.b[i]>d.b[j])
{
m++;
j++;
}
else
{
m++;
i++;j++;
}
}
while(i<l1)
{
m++;
i++;
}
while(j<l2)
{
m++;j++;
}
if(m==k)
return 1;
return 0;
}
int main()
{
name a[250];
int no,n,k,l,i;
cin>>no;
while(no--)
{
cin>>n>>k;
for(i=0;i<n;i++)
{
cin>>a[i].len;
for(int j=0;j<a[i].len;j++)
cin>>a[i].b[j];
}
/*for(i=0;i<n;i++)
{
l=a[i].len;
sort(a[i].b,a[i].b+l);
}*/
l=0;
for(i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
if(count(a[i],a[j],k))
l++;
}
cout<<l<<"\n";
}
return 0;
}