比赛链接: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. 改进你的c#代码的5个技巧(三)

    本文完全独立于前两篇文章.如果你喜欢它们,我希望你也会喜欢这个.在上一篇文章中,我展示了哪种方法更快,并比较了代码的执行速度.在本文中,我将展示不同代码片段的内存消耗情况.为了显示内存映射和分配图,我 ...

  2. 【JavaWeb】JSP 页面

    JSP 页面 简介 JSP(Java Server Pages),即 Java 的服务器页面.它的主要作用是代替 Servlet 程序回传 HTML 页面的数据,因为 Servlet 程序回传 HTM ...

  3. 剑指offer 面试题3:数组中重复的数字

    题目描述 在一个长度为n的数组里的所有数字都在0到n-1的范围内. 数组中某些数字是重复的,但不知道有几个数字是重复的.也不知道每个数字重复几次.请找出数组中任意一个重复的数字. 例如,如果输入长度为 ...

  4. LeetCode198--打家劫舍问题

    题目 你是一个专业的小偷,计划偷窃沿街的房屋.每间房内都藏有一定的现金,影响你偷窃的唯一制约因素就是相邻的房屋装有相互连通的防盗系统,如果两间相邻的房屋在同一晚上被小偷闯入,系统会自动报警. 给定一个 ...

  5. 在MongoDB中执行查询与创建索引

    实验目的: (1)掌握MongoDB中数据查询的方法: (2)掌握MongoDB中索引及其创建: 实验内容: 一. MongoDB中数据查询的方法: (1)find函数的使用: (2)条件操作符: a ...

  6. scaffoldingTools

    脚手架工具 脚手架工具概要(前端工程化的发起者) 脚手架的本质作用:创建项目基础架构.提供项目规范和约定 相同的组织结构 相同的开发规范 相同的模块依赖 相同的工具配置 相同的基础代码 举例:IDE创 ...

  7. Linux应急响应--入侵排查

    1.入侵者可能会删除机器的日志信息,可以查看日志信息是否还存在或者是否被清空,相关命令示例: ll -h /var/log/*  系统日志一般都存在/var/log下常用的系统日志如下:核心启动日志: ...

  8. oracle绑定变量测试及性能对比

    1.创建测试数据 2.查看cursor_sharing的值 SQL> show parameter cursor_sharing; NAME TYPE VALUE --------------- ...

  9. Poj-P3468题解【线段树】

    本文为原创,转载请注明:http://www.cnblogs.com/kylewilson/ 题目出处: http://poj.org/problem?id=3468 题目描述: 给N个数A1, A2 ...

  10. Windows下nginx设置开机自启动

    第一步:下载 WinSW https://github.com/winsw/winsw/releases/download/v2.10.3/WinSW.NET4.exe 64位系统 https://g ...