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
| #include <bits/stdc++.h> #define endl '\n' #define int long long using namespace std;
void solve() { int n, m; cin >> n >> m; vector<bool> col(n + 1, false), row(n + 1, false); for (int i = 1; i <= m; i++) { int x, y; cin >> x >> y; col[x] = true; row[y] = true; } int cntr = 0, cntc = 0; for (int i = 1; i <= n; i++) { if (col[i]) cntc++; if (row[i]) cntr++; } if (cntr == n && cntc == n) cout << "NO" << endl; else cout << "YES" << endl; return; }
signed main() { ios::sync_with_stdio(false), cin.tie(nullptr); int _ = 1; cin >> _; while (_--) { solve(); } return 0; }
|