比赛链接: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. Java 中 Executors.newSingleThreadExecutor() 与Executors.newFixedThreadPool(1)有什么区别

    在研究Executors提供的线程池时自然会想到标题这个问题,既然已经有了newFixedThreadPool,为什么还要存在newSingleThreadExecutor这个方法.难道newFixe ...

  2. ctfhub技能树—信息泄露—git泄露—Log

    什么是git泄露? 当前大量开发人员使用git进行版本控制,对站点自动部署.如果配置不当,可能会将.git文件夹直接部署到线上环境.这就引起了git泄露漏洞. 打开靶机环境 查看网页内容 使用dirs ...

  3. Python eval 函数用途

    Python eval 函数用途: eval 函数可将字符串转换成列表,元组和字典 实例如下: 可以把list,tuple,dict和string相互转化. ##################### ...

  4. SAP 摘录数据集

    要在报表中创建并填充摘录数据集,需要执行三步骤:1.将要在摘录数据集中使用的记录类型定义为字段组FIELD-GROUPS该语句定义了字段组,字段组可以将几个字段组合到一个名称下,字段组不为字段保留存储 ...

  5. Redis 实战 —— 05. Redis 其他命令简介

    发布与订阅 P52 Redis 实现了发布与订阅(publish/subscribe)模式,又称 pub/sub 模式(与设计模式中的观察者模式类似).订阅者负责订阅频道,发送者负责向频道发送二进制字 ...

  6. 百度文库Word下载器

    最近我妈的文库VIP用完了,但还有很多资源要下载,于是我便在网上找下载工具. 总算找到个完美的!(虽然没界面) 既然没界面,那就自己写一个呗! 原作者 该程序的下载和写入部分由地球守卫者制作 原文链接 ...

  7. 冷饭新炒:理解JDK中UUID的底层实现

    前提 UUID是Universally Unique IDentifier的缩写,翻译为通用唯一标识符或者全局唯一标识符.对于UUID的描述,下面摘录一下规范文件A Universally Uniqu ...

  8. 数位DP笔记

    数位DP 1.定义: 数位dp是一种计数用的dp,一般就是要统计一个区间[L,R]内满足一些条件数的个数.所谓数位dp,字面意思就是在数位上进行dp: 数位的含义:一个数有个位.十位.百位.千位... ...

  9. 系列trick - 随机

    系列trick - 随机 不断更新中,欢迎来提供idea 随机的字符串 出现次数 \(\ge 2\) 的子串期望长度是 \(\log n\) 两个随机串的期望LCP,LCSuf,LCSub长度是 \( ...

  10. HDU1823 Luck ans Love 二维线段树

    Luck and Love HDU - 1823 世界上上最远的距离不是相隔天涯海角 而是我在你面前 可你却不知道我爱你                 ―― 张小娴 前段日子,枫冰叶子给Wiskey ...