diff options
| author | omagdy7 <omar.professional8777@gmail.com> | 2022-11-10 16:05:26 +0200 |
|---|---|---|
| committer | omagdy7 <omar.professional8777@gmail.com> | 2022-11-10 16:05:26 +0200 |
| commit | 95422138588572e08a1ee78e654741874f11cfa0 (patch) | |
| tree | 1a03ad9c57788546e804724ed4507f46c385263d /codeforces/CowardlyRooks | |
| parent | 42e25addbbce62e8bb43ab587b21c5bccb495bfb (diff) | |
| download | competitive-programming-95422138588572e08a1ee78e654741874f11cfa0.tar.xz competitive-programming-95422138588572e08a1ee78e654741874f11cfa0.zip | |
Added some new problems
Diffstat (limited to 'codeforces/CowardlyRooks')
| -rwxr-xr-x | codeforces/CowardlyRooks/main | bin | 0 -> 67656 bytes | |||
| -rw-r--r-- | codeforces/CowardlyRooks/main.cpp | 77 | ||||
| -rw-r--r-- | codeforces/CowardlyRooks/main_input0.txt | 6 | ||||
| -rw-r--r-- | codeforces/CowardlyRooks/main_input1.txt | 6 | ||||
| -rw-r--r-- | codeforces/CowardlyRooks/main_output0.txt | 2 | ||||
| -rw-r--r-- | codeforces/CowardlyRooks/main_output1.txt | 1 |
6 files changed, 92 insertions, 0 deletions
diff --git a/codeforces/CowardlyRooks/main b/codeforces/CowardlyRooks/main Binary files differnew file mode 100755 index 0000000..9768b26 --- /dev/null +++ b/codeforces/CowardlyRooks/main diff --git a/codeforces/CowardlyRooks/main.cpp b/codeforces/CowardlyRooks/main.cpp new file mode 100644 index 0000000..0c1f7e5 --- /dev/null +++ b/codeforces/CowardlyRooks/main.cpp @@ -0,0 +1,77 @@ +#include<bits/stdc++.h> + +using namespace std; + +using ll = long long; +using pi = pair<int, int>; +using vpi = vector<pi>; +using vi = vector<int>; +using vvi = vector<vi>; +using vll = vector<long long>; +using mpii = map<int, int>; +using mpll = map<ll, ll>; +using db = long double; + +#define pb push_back +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound + +const int MOD = (int)1e9 + 7; +const db PI = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +string solve() { + int n, m; + cin >> n >> m; + vector<vector<bool>> v(n, vector<bool>(n, false)); + vpi points; + for (int i = 0; i < m; i++) { + int x, y; + cin >> x >> y; + points.pb(make_pair(x, y)); + } + for (auto p : points) { + v[p.first - 1][p.second - 1] = 1; + for (auto pp : points) { + if(pp != p) { + for (int i = 0; i < n; i++) { + v[pp.first - 1][i]=1; + cerr << v[pp.first - 1][i] << endl; + } + for (int i = 0; i < n; i++) { + v[i][pp.second - 1] = 1; + } + } + } + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + if (v[i][j] == 0 && (p.first - 1 == i || p.second - 1 == j)) { + return "YES"; + } + } + } + } + return "NO"; +} + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--) { + cout << solve() << '\n'; + } +} + +/* stuff you should look for: + --------------------------- + * special cases (n=1?) + * int overflow, array bounds + * do smth instead of nothing and stay organized + * WRITE STUFF DOWN + * DON'T GET STUCK ON ONE APPROACH + */ diff --git a/codeforces/CowardlyRooks/main_input0.txt b/codeforces/CowardlyRooks/main_input0.txt new file mode 100644 index 0000000..d314945 --- /dev/null +++ b/codeforces/CowardlyRooks/main_input0.txt @@ -0,0 +1,6 @@ +2 +2 2 +1 2 +2 1 +3 1 +2 2 diff --git a/codeforces/CowardlyRooks/main_input1.txt b/codeforces/CowardlyRooks/main_input1.txt new file mode 100644 index 0000000..a7b200d --- /dev/null +++ b/codeforces/CowardlyRooks/main_input1.txt @@ -0,0 +1,6 @@ +1 +4 4 +1 4 +2 2 +2 3 +4 1 diff --git a/codeforces/CowardlyRooks/main_output0.txt b/codeforces/CowardlyRooks/main_output0.txt new file mode 100644 index 0000000..b84a237 --- /dev/null +++ b/codeforces/CowardlyRooks/main_output0.txt @@ -0,0 +1,2 @@ +NO +YES diff --git a/codeforces/CowardlyRooks/main_output1.txt b/codeforces/CowardlyRooks/main_output1.txt new file mode 100644 index 0000000..d2bb323 --- /dev/null +++ b/codeforces/CowardlyRooks/main_output1.txt @@ -0,0 +1 @@ +YES
\ No newline at end of file |
