From 95422138588572e08a1ee78e654741874f11cfa0 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Thu, 10 Nov 2022 16:05:26 +0200 Subject: Added some new problems --- codeforces/CowardlyRooks/main | Bin 0 -> 67656 bytes codeforces/CowardlyRooks/main.cpp | 77 ++++++++++++++++++++++++++++++ codeforces/CowardlyRooks/main_input0.txt | 6 +++ codeforces/CowardlyRooks/main_input1.txt | 6 +++ codeforces/CowardlyRooks/main_output0.txt | 2 + codeforces/CowardlyRooks/main_output1.txt | 1 + 6 files changed, 92 insertions(+) create mode 100755 codeforces/CowardlyRooks/main create mode 100644 codeforces/CowardlyRooks/main.cpp create mode 100644 codeforces/CowardlyRooks/main_input0.txt create mode 100644 codeforces/CowardlyRooks/main_input1.txt create mode 100644 codeforces/CowardlyRooks/main_output0.txt create mode 100644 codeforces/CowardlyRooks/main_output1.txt (limited to 'codeforces/CowardlyRooks') diff --git a/codeforces/CowardlyRooks/main b/codeforces/CowardlyRooks/main new file mode 100755 index 0000000..9768b26 Binary files /dev/null and b/codeforces/CowardlyRooks/main differ 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 + +using namespace std; + +using ll = long long; +using pi = pair; +using vpi = vector; +using vi = vector; +using vvi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +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> v(n, vector(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 -- cgit v1.2.3