From ee1f0db08b1dc7f1498708a7e5b08b648980f04f Mon Sep 17 00:00:00 2001 From: Frederick Chen Date: Sat, 19 Apr 2025 10:09:06 +0800 Subject: [PATCH] New contest code: AtCoder Beginner Contest 390 https://atcoder.jp/contests/abc390 Signed-off-by: Frederick Chen --- atcoder/abc390/A_12435.cpp | 34 +++++++++++ atcoder/abc390/B_Geometric_Sequence.cpp | 33 ++++++++++ .../abc390/C_Paint_to_make_a_rectangle.cpp | 60 +++++++++++++++++++ 3 files changed, 127 insertions(+) create mode 100644 atcoder/abc390/A_12435.cpp create mode 100644 atcoder/abc390/B_Geometric_Sequence.cpp create mode 100644 atcoder/abc390/C_Paint_to_make_a_rectangle.cpp diff --git a/atcoder/abc390/A_12435.cpp b/atcoder/abc390/A_12435.cpp new file mode 100644 index 0000000..4ccbd90 --- /dev/null +++ b/atcoder/abc390/A_12435.cpp @@ -0,0 +1,34 @@ +#include +#define lo long long +#define INF INT_MAX +#define LLM LONG_LONG_MAX + +using namespace std; +const int N = 1e7 + 10; +/* + toothless. #17 + @fredcss_dev +*/ + +int a[N], b[N]; + +signed main() +{ + for (int i = 1; i <= 5; i++) { + cin >> a[i]; + b[i] = a[i]; + } + if (a[1] == 1 && a[2] == 2 && a[3] == 3 && a[4] == 4 && a[5] == 5) { + puts("No"); + return 0; + } + sort(b + 1, b + 6); + int cnt = 0, r = 0; + for (int i = 1; i <= 5; i++) { + if (a[i] != b[i]) cnt++; + if (a[i] != b[i] && i != 1 && a[i - 1] != b[i - 1]) r = 1; + } + if (cnt == 2 && r == 1) puts("Yes"); + else puts("No"); + return 0; +} \ No newline at end of file diff --git a/atcoder/abc390/B_Geometric_Sequence.cpp b/atcoder/abc390/B_Geometric_Sequence.cpp new file mode 100644 index 0000000..fe24970 --- /dev/null +++ b/atcoder/abc390/B_Geometric_Sequence.cpp @@ -0,0 +1,33 @@ +#include +#define lo long long +#define INF INT_MAX +#define LLM LONG_LONG_MAX + +using namespace std; +const lo N = 1e7 + 10; +/* + toothless. #17 + @fredcss_dev +*/ + +lo n; +lo a[N], b; +bool flag = 0; + +signed main() +{ + cin >> n; + for (int i = 1; i <= n; i++) { + cin >> a[i]; + } + for (int i = 3; i <= n; i++) + { + if (a[i] * a[1] != a[i - 1] * a[2]) + { + puts("No"); + return 0; + } + } + puts("Yes"); + return 0; +} \ No newline at end of file diff --git a/atcoder/abc390/C_Paint_to_make_a_rectangle.cpp b/atcoder/abc390/C_Paint_to_make_a_rectangle.cpp new file mode 100644 index 0000000..cc4ad05 --- /dev/null +++ b/atcoder/abc390/C_Paint_to_make_a_rectangle.cpp @@ -0,0 +1,60 @@ +#include +#define lo long long +#define INF INT_MAX +#define LLM LONG_LONG_MAX + +using namespace std; +const int N = 1e7 + 10; +/* + toothless. #17 + @fredcss_dev +*/ + +bool f(int h, int w, vector& g) +{ + int top = h, b = -1, l = w, r = -1; + for (int i = 0; i < h; i++) { + for (int j = 0; j < w; j++) { + if (g[i][j] == '#') { + top = min(top, i); + b = max(b, i); + l = min(l, j); + r = max(r, j); + } + } + } + if (b == -1) return true; + for (int i = top; i <= b; i++) { + for (int j = l; j <= r; j++) { + if (g[i][j] == '.') return false; + } + } + for (int i = 0; i < h; i++) { + for (int j = 0; j < w; j++) { + if (i < top || i > b || j < l || j > r) { + if (g[i][j] == '#') return false; + } + } + } + return true; +} + +signed main() +{ + int h, w; + cin >> h >> w; + if (h == 1 && w == 1) { + puts("Yes"); + return 0; + } + vector g(h); + for (int i = 0; i < h; i++) { + cin >> g[i]; + } + if (f(h, w, g)) { + cout << "Yes" << endl; + } else { + cout << "No" << endl; + } + return 0; +} \ No newline at end of file