比赛链接: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. 【JavaWeb】Servlet 程序

    Servlet 程序 Servlet Servlet 是在 Web 服务器中运行的小型 Java 程序.Servlet 通常通过 HTTP(超文本传输​​协议)接收和响应来自 Web 客户端的请求. ...

  2. IPC 经典问题:Sleeping Barber Problem

    完整代码实现: #include <stdio.h> #include <unistd.h> #include <time.h> #include <stdl ...

  3. Spring源码深度解析之事务

    Spring源码深度解析之事务 目录 一.JDBC方式下的事务使用示例 (1)创建数据表结构 (2)创建对应数据表的PO (3)创建表和实体之间的映射 (4)创建数据操作接口 (5)创建数据操作接口实 ...

  4. 微信小程序request请求的封装

    目录 1,前言 2,实现思路 3,实现过程 3.1,request的封装 3.2,api的封装 4,实际使用 1,前言 在开发微信小程序的过程中,避免不了和服务端请求数据,微信小程序给我们提供了wx. ...

  5. Linux 服务器安装node环境

    Linux 装 node 环境 我的是 CentOS 查看服务器是多少位系统 getconf LONG_BIT 下载地址, 下载对应的版本: http://nodejs.cn/download/ 我这 ...

  6. (十六)re模块

    正则表达式并不是Python的一部分,本质而言,正则表达式(或 RE)是一种小型的.高度专业化的编程语言.正则表达式是用于处理字符串的强大工具,很多编程语言都支持正则表达式的语法. 字符匹配分为普通字 ...

  7. 创建一个简单MyBatis程序

    文章目录 MyBatis基础 MyBatis 简介 创建一个MyBatis程序 1. 创建Java项目 2. 加载MyBatis包 3. 编写POJO类和映射文件 4.创建mybatis-config ...

  8. 最新详解android自动化无障碍服务accessibilityservice以及高版本问题_1_如何开启获得无障碍

    前言 无障碍服务accessibilityservice是什么 简单来说 无障碍服务就是一个为残障人士 尤其是视觉障碍人士提供的一个帮助服务.具体就是可以识别控件 文字 可以配合语音助手 操作和 使用 ...

  9. 1V升3V芯片,1V升3.3V芯片,大电流的,低功耗

    一般来说,1V的电压实在很低了,即使是干电池的话,再1V时,也是基本属于没电状态了.还有一种是干电池输出电流大时,也会把干电池的电压从1.5V拉低到1V左右. 更多的是客户对于1V时要能升到3V或者3 ...

  10. Docker 建站小记

    一,前言 Docker 建站小记,我使用了四个镜像来搭建:nginx,certbot,mysql,gradle.欢迎访问:https://www.zzk0.top 这个网页是从 github 上找的个 ...