-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB_Diameter_of_Graph.cpp
More file actions
45 lines (38 loc) · 914 Bytes
/
B_Diameter_of_Graph.cpp
File metadata and controls
45 lines (38 loc) · 914 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
#include <bits/stdc++.h>
using namespace std;
// First you make it work, then you can always make it beautiful
#define int long long
void solve() {
int n, m, k;
cin >> n >> m >> k;
if(m > n*(n-1)/2 || m < n - 1) {
cout << "NO\n";
return;
}
if(n == 1) {
if(k > 1) cout << "YES\n";
else cout << "NO\n";
return;
}
if(k <= 2) {
cout << "NO\n";
return;
}
if(k == 3) {
if(m == n*(n-1)/2) cout << "YES\n";
else cout << "NO\n";
return;
}
cout << "YES\n";
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int _;
cin >> _;
while (_-->0) {
solve();
}
return 0;
}