New contest code: AtCoder Beginner Contest 390

https://atcoder.jp/contests/abc390

Signed-off-by: Frederick Chen <seventeen@ohdragonboi.cn>
This commit is contained in:
Frederick Chen 2025-04-19 10:09:06 +08:00
parent 05b57f949c
commit ee1f0db08b
3 changed files with 127 additions and 0 deletions

View File

@ -0,0 +1,34 @@
#include <bits/stdc++.h>
#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;
}

View File

@ -0,0 +1,33 @@
#include <bits/stdc++.h>
#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;
}

View File

@ -0,0 +1,60 @@
#include <bits/stdc++.h>
#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<string>& 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<string> 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;
}