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

话不多说,直接来干货:

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. setTimeout与setInterval有何区别?

    ①setTimeout和setInterval的语法相同.它们都有两个参数,一个是将要执行的代码字符串,还有一个是以毫秒为单位的时间间隔,当过了那个时间段之后就将执行那段代码. ②不过这两个函数还是有 ...

  2. 【原生JS】制作网页头部刷新进度条

    之前的某次番啬看到油管上有这么一个进度条,当时觉得挺好玩,一直想着做一个试试,刚才弄了一下写了一个不算太好看的简陋版本,哈哈. (本博客刷新会头部会出现,因为并没有真正的参与到浏览器加载是否完整这个渲 ...

  3. Python--day26--反射

    反射对象的属性:(非常重要) getattr(类名,‘属性名’):获得属性值 使用getattr的好处:需要查看某个属性值的时候,不用再在代码中用if else elif 去判断输入(input函数) ...

  4. tensorflow学习笔记(二十五):ConfigProto&GPU

    tensorflow ConfigPrototf.ConfigProto一般用在创建session的时候.用来对session进行参数配置 with tf.Session(config = tf.Co ...

  5. Python--day46--mysql存储过程(不常用)(包含防sql注入)

    一.存储过程: 优点:只要传很少的数据到数据库就可以了  缺点:dba管理数据库的时候可能会对数据库进行了更改了那一坨sql语句. 二.创建存储过程: 1.简单 创建存储过程: Python中使用结果 ...

  6. java 泛型的嵌套(map例子)

    package july7; //泛型加Map的输出! import java.util.Iterator; import java.util.Map; import java.util.Map.En ...

  7. java 利用TCP上传文件

    从客户端上传到服务器端,其实本质上也就是复制! package july76net; //上传文件(文本) import java.io.BufferedReader; import java.io. ...

  8. UVA 12563 "Jin Ge Jin Qu hao" (背包)

    传送门 debug了好一会,突然发现,输出错了,emmm......... 明天再写debug历程: (PS:ipad debug是真的繁琐) 题意: 题解: 尽管题干中给的 t 的范围很大,但是 t ...

  9. linux 内核定时器

    无论何时你需要调度一个动作以后发生, 而不阻塞当前进程直到到时, 内核定时器是给你 的工具. 这些定时器用来调度一个函数在将来一个特定的时间执行, 基于时钟嘀哒, 并且 可用作各类任务; 例如, 当硬 ...

  10. VUE框架思想

    学习VUE的第一步就是先了解这个框架的的核心思想 Vue.js的核心思想就是,它是一套__渐进式的自底层向上增量开发__的__MVVM__结构的框架 什么是框架? 简单的讲,框架就是将与业务无关的重复 ...