forked from Sahaj-Bamba/HacktoberTrial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjms.cpp
More file actions
44 lines (37 loc) · 672 Bytes
/
jms.cpp
File metadata and controls
44 lines (37 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
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m,k;
cin>>n>>m>>k;
int aa[n+1][n+1];
memset(aa,sizeof(aa),0);
while(m--)
{
int a,b;
cin>>a>>b;
aa[a][b]=1;
aa[b][a]=1;
}
int c,d,k,sum=0,flag=0;
for (c = 1; c < n+1; c++) {
for (d = 1; d < n+1; d++) {
for (k = 1; k < n+1; k++) {
sum = sum + aa[c][k]*aa[k][d];
}
if(sum>=k&&c!=d)
{
flag=1;
break;
}
aa[c][d] = sum;
sum = 0;
}
if(flag==1)
break;
}
if(flag==1)
cout<<"YES\n";
else
cout<<"NO\n";
}