总的来说,这次的题目比较水,然而菜菜的我并没有把所有题目都做完,

话不多说,直接来干货:

A:Next Alphabet#

题目链接:https://atcoder.jp/contests/abc151/tasks/abc151_a

题目描述:Given is a lowercase English letter C that is not z. Print the letter that follows C
in alphabetical order.
大致解读:给你一个小写字母,输出这个小写字母的后一个字母(所有样例中不会有 z 字母的出现)
样例:
input :a
output:b

AC代码:

#include<iostream>
#include<cstring>
#include<string>
using namespace std;
int main(void) {
string str;
cin >> str;
printf("%c\n",str[0] + 1);
return 0;
}

B: Achieve the Goal#

题目链接:https://atcoder.jp/contests/abc151/tasks/abc151_b

题目描述:Takahashi is taking exams on N subjects. The score on each subject will be an integer between
0 and K(inclusive).He has already taken exams on N−1 subjects and scored A i points on the i-th
subject.His goal is to achieve the average score of M points or above on the N subjects. Print
the minimum number of points Takahashi needs on the final subject to achieve his goal. If the
goal is unachievable, print -1 instead.
大致解读:题目中会给你 N - 1 个数,然后需要找满足某种条件的第 N 个数,问是否存在这样的一个数,如果存在,输出这个数。
不存在,则输出 '-1'。
寻找的这个数的条件:
1、范围必须在0 ~ k(包括0 and k)
2、与前 N - 1个数的平均值在 M 及 M 之上 (英文的重要性,hh)
样例:
input :5 10 7
8 10 3 6
output :8
析题有解:初看这道题,感觉是数论,(哈哈,实际上是自己见的东西太少了,根本不是数论),然后直接就去做后面的题了,A了第三题
之后,看榜单发现大家都做了这道题,这么多人能做出来,我也一定可以,然后再去读题,发现竟然如此水,主要还是自己
英文不好,题没读懂,哈哈哈。

AC代码:

#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 105;
int n,k,m,sum;
float aver;
int main(void) {
cin >> n >> k >> m;
sum = 0;
for(int i = 1; i <= n - 1; i ++) {
int num;
cin >> num;
sum += num;
}
for(int j = 0; j <= k; j ++) {
aver = (sum + j) * 1.0 / n;
if(aver >= m) {
cout << j << endl;
return 0;
}
}
cout << "-1" << endl;
return 0;
}

C:Welcome to AtCoder#

题目链接:https://atcoder.jp/contests/abc151/tasks/abc151_c

题目描述:Takahashi participated in a contest on AtCoder.The contest had N problems.
Takahashi made M submissions during the contest.The i-th submission was made
for the pi-th problem and received the verdict Si (AC or WA). The number of
Takahashi's correct answers is the number of problems on which he received
an AC once or more.The number of Takahashi's penalties is the sum of the following
count for the problems on which he received an AC once or more: the number of WAs
received before receiving an AC for the first time on that problem.
Find the numbers of Takahashi's correct answers and penalties.
大致解读:
与我们平常在网站上做题目交题时评测机类似,根据 AC 和 WA 来判断 A 了几道题,在 A 完给出的所以
题之前我们 WA 掉了几次,最后输出 AC 题目结果和 我们所有 WA 了的次数。
注意:一道题目 AC 过后之后 WA 的结果就不再被累计(常识的东西就不再一一介绍了,可以自己找OJ测试一下)
样例 :
input : 2 5
1 WA
1 AC
2 WA
2 AC
2 WA
outout: 2 2

AC代码:

    #include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<map>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];
map<int,int>maps;
map<int,int>::iterator it;
int n,m;
int ac = 0,wa = 0;
int main(void) {
void solve();
cin >> n >> m;
ac = wa = 0;
solve();
return 0;
}
void solve() {
if(m == 0) {
cout << 0 << " " << 0 << endl;
return ;
}
int num;
string vis;
for(int i = 1; i <= m; i ++) {
cin >> num >> vis;
if(maps[num] == -1) continue;
if(vis == "AC") {
wa += maps[num];
ac += 1;
maps[num] = -1;
continue;
}
maps[num] ++;
}
maps.clear();
cout << ac << " " << wa << endl;
return ;
}

D:Maze Master#

题目链接:https://atcoder.jp/contests/abc151/tasks/abc151_d

题目描述:Takahashi has a maze, which is a grid of H × W squares with H horizontal rows and
W vertical columns.The square at the i-th row from the top and the j-th column is
a "wall" square if Sij is #, and a "road" square if Sij is ..
From a road square, you can move to a horizontally or vertically adjacent road square.
You cannot move out of the maze, move to a wall square, or move diagonally.Takahashi will
choose a starting square and a goal square, which can be any road squares, and give the maze to Aoki.
Aoki will then travel from the starting square to the goal square, in the minimum number of moves required.
In this situation, find the maximum possible number of moves Aoki has to make.
大致解读:有一个 H * W 的迷宫,自己任意定义一个起点和终点,找到一个最远的距离且是存在一条最短路径,输出这条路的最短步数。
数值范围:1≤H,W≤20
样例:
input :3 3
...
...
...
output: 4
input:3 5
...#.
.#.#.
.#...
output: 10
析题有解:这道题有一个需要特别注意的地方,就是数值范围,最大是 20 ,这么小的范围,当然暴力来一发咯,哈哈。
起点和终点都没有给我们,而我们又要求一个最大值,只能逐个遍历每一个合适的点,寻找满足这个点的合
适路径的最少步数。
考察算法:BFS经典走迷宫

AC代码:

方法一(结构体的运用 + 标记):
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<string.h>
#include<limits.h>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
const int maxn = 25;
char str[maxn][maxn];
int vis[maxn][maxn];
struct node { // 结构体将其信息绑定到一起
int x,y,step;
} dot[maxn];
int dir[][2] = {{1,0},{-1,0},{0,1},{0,-1}}; // 方向
int n,m;
int ans = 0,res = 0;
int main(void) {
int BFS(int start_x,int start_y);
scanf("%d%d",&n,&m);
for(int i = 1; i <= n; i ++) {
for(int j = 0; j <= m; j ++) { // 有换行字符,所以从 0 开始
scanf("%c",&str[i][j]);
}
}
ans = 0;
for(int i = 1; i <= n; i ++) {
for(int j = 1; j <= m; j ++) {
if(str[i][j] == '#') continue;
res = BFS(i,j);
ans = max(ans,res);
}
}
cout << ans << endl;
return 0;
} bool Check(int x,int y) {
if(x < 1 || y < 1 || x > n || y > m) return false;
if(vis[x][y] || str[x][y] == '#') return false;
if(str[x][y] == '.') return true;
} int BFS(int start_x,int start_y) {
memset(vis,0,sizeof(vis)); // 复原
int count = 0;
queue<node>queues;
while(!queues.empty()) queues.pop();
node first,second;
first.x = start_x,first.y = start_y,first.step = 0;
queues.push(first);
vis[start_x][start_y] = 1;
while(!queues.empty()) {
first = queues.front();
queues.pop();
count = max(count,first.step); // 每次进行比较得到最大的值
for(int i = 0; i < 4; i ++) {
second.x = first.x + dir[i][0];
second.y = first.y + dir[i][1];
if(!Check(second.x,second.y)) continue; // 注意这里用 ! (这里卡了好久,一定要记得自己写的Check函数返回的是什么)
second.step = first.step + 1;
queues.push(second);
vis[second.x][second.y] = 1;
}
}
return count;
} 方法二(pair的运用,参考大佬写的,感觉相对于结构体来说,更好用一点,再次特地感谢那位无名大佬): 大致思路类似: #include<iostream>
#include<algorithm>
#include<cstring>
#include<string.h>
#include<limits.h>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set> #define P pair<int,int>
#define x first
#define y second using namespace std;
const int maxn = 25;
char str[maxn][maxn];
int num[maxn][maxn];
int dir[][2] = {{1,0},{-1,0},{0,1},{0,-1}};
int n,m,ans,res; queue<P>Q; int main(void) {
int BFS(int start_x,int start_y);
scanf("%d%d",&n,&m);
for(int i = 1; i <= n; i ++) {
for(int j = 0; j <= m; j ++) {
scanf("%c",&str[i][j]);
}
}
ans = 0,res = 0;
for(int i = 1; i <= n; i ++) {
for(int j = 1; j <= m; j ++ ) {
if(str[i][j] == '#') continue;
res = BFS(i,j);
ans = max(ans,res);
}
}
cout << ans << endl;
return 0;
} bool Check(int x,int y) {
if(x < 1 || y < 1 || x > n || y > m) return false;
if(str[x][y] == '#' || num[x][y]) return false;
if(str[x][y] == '.') return true;
} int BFS(int start_x,int start_y) {
P a,b;
int count = 0;
memset(num,0,sizeof(num));
while(!Q.empty()) Q.pop();
a.x = start_x,a.y = start_y;
Q.push(a);
while(!Q.empty()) {
a = Q.front();
Q.pop();
count = max(count,num[a.x][a.y]);
int v = num[a.x][a.y];
for(int i = 0; i < 4; i ++) {
b.x = a.x + dir[i][0];
b.y = a.y + dir[i][1];
if(!Check(b.x,b.y)) continue;
if(b.x != start_x || b.y != start_y) { // 要保证不会回到最初的点,因为这种方法我们没有进行标记
num[b.x][b.y] = v + 1;
Q.push(b);
}
/*
如果不加特殊判断的话就会出现错误,下面是特殊样例:
2 2
#.
#.
*/ }
}
return count;
}
知识总结:
1、复习了 map 容器的运用,更加熟练。
2、对迷宫问题有了更深一步的了解,同时对 BFS 也算回顾复习了一下(Check语句一定要认真,弄清楚返回的是什么)
3、pair<int,int> 的应用,相对于结构体来说,这个的应用更方便一点。
#赛后小结:#
1、认真读题,认真读题,一定要真正读题,有可能一个小小的细节就会导致大错误。
2、大胆一点,有想法就要尝试一下。
3、坚持到比赛最后一秒,不要因为时间快到了就不去想了,也不要因为别人都做出来了而不再去尝试。

···

能力有限,如有写的不到位的地方,望路过的朋友留下您的建议,在下会细心改正,万分感谢。

后续更新 ing............

···

AtCoder Beginner Contest 151 题解报告的更多相关文章

  1. AtCoder Beginner Contest 154 题解

    人生第一场 AtCoder,纪念一下 话说年后的 AtCoder 比赛怎么这么少啊(大雾 AtCoder Beginner Contest 154 题解 A - Remaining Balls We ...

  2. AtCoder Beginner Contest 153 题解

    目录 AtCoder Beginner Contest 153 题解 A - Serval vs Monster 题意 做法 程序 B - Common Raccoon vs Monster 题意 做 ...

  3. AtCoder Beginner Contest 177 题解

    AtCoder Beginner Contest 177 题解 目录 AtCoder Beginner Contest 177 题解 A - Don't be late B - Substring C ...

  4. AtCoder Beginner Contest 184 题解

    AtCoder Beginner Contest 184 题解 目录 AtCoder Beginner Contest 184 题解 A - Determinant B - Quizzes C - S ...

  5. AtCoder Beginner Contest 173 题解

    AtCoder Beginner Contest 173 题解 目录 AtCoder Beginner Contest 173 题解 A - Payment B - Judge Status Summ ...

  6. AtCoder Beginner Contest 172 题解

    AtCoder Beginner Contest 172 题解 目录 AtCoder Beginner Contest 172 题解 A - Calc B - Minor Change C - Tsu ...

  7. AtCoder Beginner Contest 169 题解

    AtCoder Beginner Contest 169 题解 这场比赛比较简单,证明我没有咕咕咕的时候到了! A - Multiplication 1 没什么好说的,直接读入两个数输出乘积就好了. ...

  8. AtCoder Beginner Contest 148 题解

    目录 AtCoder Beginner Contest 148 题解 前言 A - Round One 题意 做法 程序 B - Strings with the Same Length 题意 做法 ...

  9. AtCoder Beginner Contest 115 题解

    题目链接:https://abc115.contest.atcoder.jp/ A Christmas Eve Eve Eve 题目: Time limit : 2sec / Memory limit ...

随机推荐

  1. jieba gensim 相似度实现

    博客引自:https://www.cnblogs.com//DragonFire/p/9220523.html 简单的问答已经实现了,那么问题也跟着出现了,我不能确定问题一定是"你叫什么名字 ...

  2. Codeforces Round #170 (Div. 1 + Div. 2)

    A. Circle Line 考虑环上的最短距离. B. New Problem \(n\) 个串建后缀自动机. 找的时候bfs一下即可. C. Learning Languages 并查集维护可以沟 ...

  3. 如何查看linux中的ssh端口开启状态

    netstat -anp |grep 22 netstat -anp |grep sshlsof -i :22

  4. java接口和抽象类的比较

    相同点: 都位于继承的顶端,用于被其他实现或继承; 都不能实例化; 都包含抽象方法,其子类都必须覆写这些抽象方法;   区别: 抽象类为部分方法提供实现,避免子类重复实现这些方法,提供代码重用性;接口 ...

  5. 获取 Nuget 版本号

    本文告诉大家通过命令行获取 Nuget 的版本号 在 Nuget 中没有 -version 和 -v 和 --version 等写法,只需要直接输入 nuget 在第一行就会显示版本号 nuget N ...

  6. 消息驱动Bean

    消息驱动bean是专门用来处理基于消息请求的组件.MDB负责处理消息,而EJB容器则负责处理服务(事务,安全,并发,消息确认等),使Bean的开发者集中精力在处理消息的业务逻辑上. 消息驱动Bean. ...

  7. Windows Server Core Remote Manage Hyper-V

    原帖:https://serverfault.com/questions/852144/how-do-i-remotely-manage-hyper-v-2016-standalone-via-win ...

  8. Team Foundation Server 2015使用教程【2】:默认团队成员添加

    官方文档:https://www.visualstudio.com/en-us/docs/setup-admin/add-users

  9. Python 实现栈与队列

    #基于Python2.7 #基于顺序表实现 #发现用Python写题时,没有像写C++时方便的STL可用,不过查阅资料之后发现用class实现也很简洁,不过效率应该不是很高 Python实现栈并使用: ...

  10. jQuery无new创建对象原理

    // jQuery 无new 创建对象套路 (function(g,undefined){ var foo = function(){ return new foo.fn.init(); }; foo ...