AtCoder Beginner Contest 218 A~D
比赛链接:Here
A - Weather Forecas
水题,判断 YES
B - qwerty
题意:给出
void solve() {
int n = 26;
for (int i = 0, x; i < n; ++i) {
cin >> x;
cout << char('a' + x - 1);
}
}
C - Shapes
题意:在
数据范围:
思路:
可以把
然后把
因为要是 yes
的话
那枚举每个
再把 yes
,如果旋转出来的所有情况都无法平移到 No
。
struct node {int x, y;};
vector<node>v1, v2, v3, v4, v5;
bool cmp(node a, node b) { return a.x == b.x ? a.y < b.y : a.x < b.x; }
bool check(vector<node> a, vector<node>b) {
int n = a.size();
int lx = a[0].x - b[0].x;
int ly = a[0].y - b[0].y;
for (int i = 0; i < n; i++) {
if (a[i].x - b[i].x != lx) return false;
if (a[i].y - b[i].y != ly) return false;
}
return true;
}
void solve() {
int n; cin >> n;
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j) {
char c; cin >> c;
if (c == '#') {
v1.push_back({i, j});
v2.push_back({j, n - i + 1});
v3.push_back({n - j + 1, i});
v5.push_back({n - i + 1, n - j + 1});
}
}
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j) {
char c; cin >> c;
if (c == '#')
v4.push_back({i, j});
}
if (v1.size() != v4.size()) {cout << "No\n"; return ;}
if (v1.size() == 0 and v2.size() == 0) {cout << "Yes\n"; return ;}
sort(v1.begin(), v1.end(), cmp);
sort(v2.begin(), v2.end(), cmp);
sort(v3.begin(), v3.end(), cmp);
sort(v4.begin(), v4.end(), cmp);
sort(v5.begin(), v5.end(), cmp);
int f = 0;
if (check(v1, v4)) f = 1;
if (check(v2, v4)) f = 1;
if (check(v3, v4)) f = 1;
if (check(v5, v4)) f = 1;
cout << (f ? "Yes\n" : "No\n");
}
D - Rectangles
题意:已知二维平面上
数据范围:
思路:枚举两个点作为矩形的对角线,并检查另外两个点是否也在平面上。
这样一来,一个矩形会被计算两次(两条对角线),所以答案要除以
struct node {
int x, y;
bool operator <(const node &nd) const {
if (x == nd.x) return y < nd.y;
else return x < nd.x;
}
};
void solve() {
int n; cin >> n;
int x[n + 1], y[n + 1];
map<node, int>mp;
for (int i = 1; i <= n; i++)
cin >> x[i] >> y[i], mp[(node) {x[i], y[i]}] = 1; //记录节点
ll cnt = 0;
for (int i = 1; i <= n; ++i)
for (int j = i + 1; j <= n; ++j) {
if (x[i] == x[j] || y[i] == y[j]) continue;
if (mp[(node) {x[i], y[j]}] == 1 and mp[(node) {x[j], y[i]}] == 1) cnt += 1;
}
cout << cnt / 2 << "\n";
}
EFG待补
分类:
刷题笔记: AtCoder
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· Obsidian + DeepSeek:免费 AI 助力你的知识管理,让你的笔记飞起来!
· 分享4款.NET开源、免费、实用的商城系统
· 解决跨域问题的这6种方案,真香!
· 一套基于 Material Design 规范实现的 Blazor 和 Razor 通用组件库
· 5. Nginx 负载均衡配置案例(附有详细截图说明++)
2020-09-12 Problem B - Card Constructions (构造)
2020-09-12 Problem A - Sequence with Digits (数学推导)