比赛链接:https://atcoder.jp/contests/abc176

A - Takoyaki

#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x, t;
cin >> n >> x >> t;
cout << (n + x - 1) / x * t << "\n";
}

B - Multiple of 9

#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
int mod = 0;
for (char c : s) {
mod += c - '0';
mod %= 9;
}
cout << (mod == 0 ? "Yes" : "No") << "\n";
}

C - Step

#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
long long ans = 0;
int mx = 0;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
mx = max(mx, x);
ans += mx - x;
}
cout << ans << "\n";
}

D - Wizard in Maze

#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 100;
const int dir[4][2] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}}; int h, w;
int c_h, d_h, c_w, d_w;
int ans = -1;
string MP[N];
bool vis[N][N]; struct P{
int x, y;
int cnt;
}; bool inside(int x, int y) {
return x >= 0 and x < h and y >= 0 and y < w;
} void bfs() {
deque<P> dque;
dque.push_front({c_h, c_w, 0});
while (!dque.empty()) {
auto [x, y, cnt] = dque.front();
dque.pop_front();
if (x == d_h and y == d_w) {
ans = cnt;
break;
}
if (vis[x][y]) continue;
vis[x][y] = true;
for (int i = 0; i < 4; i++) {
int nx = x + dir[i][0];
int ny = y + dir[i][1];
if (inside(nx, ny) and MP[nx][ny] == '.')
dque.push_front({nx, ny, cnt});
}
for (int nx = x - 2; nx <= x + 2; nx++) {
for (int ny = y - 2; ny <= y + 2; ny++) {
if (inside(nx, ny) and MP[nx][ny] == '.')
dque.push_back({nx, ny, cnt + 1});
}
}
}
} int main() {
cin >> h >> w;
cin >> c_h >> c_w >> d_h >> d_w;
--c_h, --c_w, --d_h, --d_w;
for (int i = 0; i < h; i++)
cin >> MP[i];
bfs();
cout << ans << "\n";
}

E - Bomber

#include <bits/stdc++.h>
using namespace std;
int main() {
int h, w;
cin >> h >> w;
int m;
cin >> m;
int mxr = 0, mxc = 0;
vector<int> row(h), col(w);
vector<pair<int, int>> v;
for (int i = 0; i < m; i++) {
int x, y;
cin >> x >> y;
--x, --y;
mxr = max(mxr, ++row[x]);
mxc = max(mxc, ++col[y]);
v.emplace_back(x, y);
}
int inter = 0;
for (auto [x, y] : v) {
if (row[x] == mxr and col[y] == mxc)
++inter;
}
int cnt_mxr = count(row.begin(), row.end(), mxr);
int cnt_mxc = count(col.begin(), col.end(), mxc);
cout << (mxr + mxc - (inter == 1ll * cnt_mxr * cnt_mxc)) << "\n";
}

参考博客

https://www.cnblogs.com/lr599909928/p/13559189.html

https://www.cnblogs.com/lr599909928/p/13559245.html

AtCoder Beginner Contest 176的更多相关文章

  1. AtCoder Beginner Contest 176 D - Wizard in Maze (BFS,双端队列)

    题意:给你一张图,"."表示能走,"#表示不能走,步行可以向四周四个方向移动一个单位,使用魔法可以移动到周围\(5\)X\(5\)的空地,问能否从起点都早终点,并求最少使 ...

  2. AtCoder Beginner Contest 176 E - Bomber (思维)

    题意:有一张\(H\)x\(W\)的图,给你\(M\)个目标的位置,你可以在图中放置一枚炸弹,炸弹可以摧毁所在的那一行和一列,问最多可以摧毁多少目标. 题解:首先我们记录某一行和某一列目标最多的数目, ...

  3. AtCoder Beginner Contest 100 2018/06/16

    A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...

  4. AtCoder Beginner Contest 052

    没看到Beginner,然后就做啊做,发现A,B太简单了...然后想想做完算了..没想到C卡了一下,然后还是做出来了.D的话瞎想了一下,然后感觉也没问题.假装all kill.2333 AtCoder ...

  5. AtCoder Beginner Contest 053 ABCD题

    A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...

  6. AtCoder Beginner Contest 136

    AtCoder Beginner Contest 136 题目链接 A - +-x 直接取\(max\)即可. Code #include <bits/stdc++.h> using na ...

  7. AtCoder Beginner Contest 137 F

    AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) ...

  8. AtCoder Beginner Contest 076

    A - Rating Goal Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Takaha ...

  9. AtCoder Beginner Contest 079 D - Wall【Warshall Floyd algorithm】

    AtCoder Beginner Contest 079 D - Wall Warshall Floyd 最短路....先枚举 k #include<iostream> #include& ...

随机推荐

  1. mac安装Navicat Premium Mac 12 破解版

    参考:https://www.cnblogs.com/lyfstorm/p/11123159.html 激活后:

  2. Session、Cookie与Token

    http协议是无状态协议 协议是指计算机通信网络中两台计算机之间进行通信所必须共同遵守的规定或规则,超文本传输协议(HTTP)是一种通信协议,它允许将超文本标记语言(HTML)文档从Web服务器传送到 ...

  3. nginx启动失败(bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket...permissions)

    nginx启动失败 nginx启动失败(bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket in a ...

  4. LeetCode349. 两个数组的交集

    题目 给定两个数组,编写一个函数来计算它们的交集. 分析 数组元素值可以很大,所以不适合直接开数组进行哈希,这里要学习另一种哈希方式:集合 集合有三种,区别见下面代码随想录的Carl大佬的表格,总结的 ...

  5. MongoDB数据库,一些的筛选过滤查询操作和db.updae()更新数据库记录遇到的坑。

    缘由:使用MongoDB时遇到一些需要查询/更新操作指定某些字段的业务场景 查询和更新指定字段就需要进行简单的筛选和过滤,也能在大数据量时减少查询消耗时间 1. 查询数据库某些指定字段,同时默认返回_ ...

  6. 《Go 语言并发之道》读后感 - 第四章

    <Go 语言并发之道>读后感-第四章 约束 约束可以减轻开发者的认知负担以便写出有更小临界区的并发代码.确保某一信息再并发过程中仅能被其中之一的进程进行访问.程序中通常存在两种可能的约束: ...

  7. 注入器(injector)

    1.0    注入器/injector 注入器是AngularJS框架实现和应用开发的关键,这是一个DI/IoC容器的实现. AngularJS将功能分成了不同类型的组件分别实现,这些组件有一个统称 ...

  8. Ansible自动化运维工具的使用

                                 Ansible自动化运维工具的使用       host lnventory 管理主机 ip  root账号密码 ssh端口 core mod ...

  9. 标准PE头属性说明

  10. ospf-lite runs over tcp / udp port 8899.

    draft-thomas-reed-ospf-lite-01 - ospf-lite https://tools.ietf.org/html/draft-thomas-reed-ospf-lite-0 ...