AtCoder Beginner Contest 176总结

由于打球又鸽了一场,快开学了好好打球!!!(狗头 还是补一补

A - Takoyaki

签到题

#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
using namespace std;
int n,x,t;
int main()
{cin>>n>>x>>t;cout<<(n+x-1)/x*t<<endl;return 0;
}

B - Multiple of 9

第一次打学校比赛的时候就有一个类似的题
不过这题直接把结论告诉了一个数是9的倍数充要条件是十进制下每一位加起来的和是9的倍数
直接让这题称为模拟题

#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
string s;
int main()
{cin>>s;ll res=0;for(auto t:s) res+=t-'0';if(res%9==0) cout<<"Yes"<<endl;else cout<<"No"<<endl;return 0;
}

C - Step

记录last前面最大的数,然后更新答案即可

#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=200010;
int a[N],n;
int main()
{cin>>n;int last=0;ll res=0;for(int i=1;i<=n;i++) cin>>a[i];for(int i=1;i<=n;i++){if(a[i]<last) res+=last-a[i];else last=a[i];}cout<<res<<endl;return 0;
}

D - Wizard in Maze

双端队列bfs,使用魔法代价为1其他代价为0,更新即可。

#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<vector>
#include<set>
#include<map>
#include<deque>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=1010;
pii start,ed;
int n,m;
char g[N][N];
int dist[N][N];
bool st[N][N];
void bfs()
{memset(dist,0x3f,sizeof dist);deque<pii> q;dist[start.x][start.y]=0;q.push_front(start);int dx[]={0,0,1,-1},dy[]={1,-1,0,0};while(q.size()){auto t=q.front();q.pop_front();if(st[t.x][t.y]) continue;st[t.x][t.y]=1;int d=dist[t.x][t.y];int a,b;for(int i=0;i<4;i++){a=t.x+dx[i],b=t.y+dy[i];if(a<1||b<1||a>n||b>m||g[a][b]=='#'||dist[a][b]<=d) continue;dist[a][b]=d;q.push_front({a,b});}for(int i=t.x-2;i<=t.x+2;i++)   {if(i<1||i>n) continue;for(int j=t.y-2;j<=t.y+2;j++){if(j<1||j>m||g[i][j]=='#'||dist[i][j]<=d+1) continue;dist[i][j]=d+1;q.push_back({i,j});}}}
}
int main()
{cin>>n>>m;cin>>start.x>>start.y;cin>>ed.x>>ed.y;for(int i=1;i<=n;i++) cin>>g[i]+1;bfs();if(dist[ed.x][ed.y]==0x3f3f3f3f) cout<<-1<<endl;else cout<<dist[ed.x][ed.y]<<endl;return 0;
}

E - Bomber

直接枚举懒得写题解了

#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<vector>
#include<set>
#include<map>
#include<deque>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=300010;
int n,m;
int k;
map<pii,int> mp;
int col[N],row[N];
int maxr,maxc;
vector<int> a,b;
int main()
{cin>>n>>m>>k;while(k--){int a,b;cin>>a>>b;mp[{a,b}]=1;row[a]++;col[b]++;maxr=max(maxr,row[a]);maxc=max(maxc,col[b]);}for(int i=1;i<=n;i++) if(row[i]==maxr) a.push_back(i);for(int j=1;j<=m;j++)if(col[j]==maxc) b.push_back(j);for(int i=0;i<a.size();i++) for(int j=0;j<b.size();j++)if(mp[{a[i],b[j]}]==0) {cout<<maxr+maxc<<endl;return 0;}cout<<maxr+maxc-1<<endl;return 0;
}

F

F不会不知道会不会补。先鸽了
要加油哦~

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/319652.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

讲重点,看趋势——Microsoft Ignite 2018的回顾和展望

一年一度的微软技术大会——Microsoft Ignite 2018上周在奥兰多召开&#xff0c;目前已经落下帷幕。我没有去现场&#xff0c;但据说这次的盛况空前&#xff0c;创下微软之最。确实&#xff0c;这些年来&#xff0c;微软内部非常重视 Iginte&#xff0c;上至最高管理层&#xf…

P4590-[TJOI2018]游园会【dp套dp】

正题 题目链接:https://www.luogu.com.cn/problem/P4590 题目大意 给出一个长度为mmm的字符串sss。 对于每个k∈[0,m]k\in[0,m]k∈[0,m]求有多少个长度为nnn的字符串满足与sss的最长公共子序列长度为kkk且不包含NOINOINOI这一个子串。 可用字符集是{N,O,I}\{N,O,I\}{N,O,I} 解…

【DP】【线段树】基站选址(luogu 2605/金牌导航 数据结构优化DP-2)

正题 luogu 2605 金牌导航 数据结构优化DP-2 题目大意 有若干个村庄在一条直线上&#xff0c;距离第一个村庄did_idi​&#xff0c;在该村庄建立基站要花费cic_ici​&#xff0c;如果在离该村不大于sis_isi​的范围内有一个基站&#xff0c;那么该村会被信号覆盖&#xff0c;…

Fake Maxpooling(2020多校第二场F)

Fake Maxpooling&#xff08;2020多校第二场F&#xff09; 文章目录题意&#xff1a;题解&#xff1a;代码&#xff1a;题意&#xff1a; 一个n * m的矩阵&#xff0c;第i行第j列的值是lcm&#xff08;i&#xff0c;j&#xff09;&#xff0c;然后给定一个 k * k的子矩阵&…

Educational Codeforces Round 94 (Rated for Div. 2)

这次做了ABCD&#xff0c;今天下午就要上学去了溜了溜了&#xff0c;早上起来补的题解。 A - String Similarity 分析可知可构造w[i]s[2*i]即可满足题意 #define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0) #pragma GCC optimize(2) #include<string> #in…

算法工程师的危机

本文为沙漠之鹰第68篇原创文章9月20号讯飞AI同传语音造假的新闻刷爆科技圈&#xff0c;科大讯飞股价应声下跌3.89%&#xff08;不是65.3%&#xff0c;标题党文章害死人&#xff09;。 吃瓜群众纷纷感慨&#xff0c;有多少人工&#xff0c;就有多少智能。小编偷换概念玩的溜AI概…

Cover the Tree(2020多校第二场C)

Cover the Tree 文章目录题意&#xff1a;题解&#xff1a;代码题意&#xff1a; 一个无向树&#xff0c;选择最少数量的链子&#xff0c;能将树上所有边覆盖&#xff0c;答案不唯一 (1≤n≤2105&#xff09; 链子就是两点之间的边 看看样例 输入 5 1 2 1 3 2 4 2 5输出 2 2…

【DP】【树状数组】折线统计(金牌导航 数据结构优化DP-1)

正题 金牌导航 数据结构优化DP-1 题目大意 平面上有n个点&#xff0c;让你选择若干点&#xff0c;连接x坐标相邻的点&#xff0c;其中连续上升或下降的为一段&#xff0c;问你有多少中选择方案&#xff0c;使得段数为k 解题思路 设fi,j,0/1f_{i,j,0/1}fi,j,0/1​为到第i个点…

AtCoder Beginner Contest 177总结

回学校第一次打AtCoder&#xff0c;感觉晚上在寝室打不在状态~~ A - Don’t be late 数学题签到 #define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0) #include<iostream> #include<algorithm> using namespace std; typedef long long ll; const in…

[模板]多项式全家桶小记(求逆,开根,ln,exp)

前言 这里的全家桶目前只包括了ln,exp,sqrtln,exp,sqrtln,exp,sqrt。还有一些类似于带余数模&#xff0c;快速幂之类用的比较少的有时间再更&#xff0c;NTTNTTNTT这种前置知识这里不多说。 还有一些基本的导数和微积分内容要了解&#xff0c;建议不懂的可以先去翻翻高二数学…

牛客网【每日一题】7月21日题目精讲—区间权值

来源&#xff1a;牛客网&#xff1a; 区间权值 时间限制&#xff1a;C/C 1秒&#xff0c;其他语言2秒 空间限制&#xff1a;C/C 1048576K&#xff0c;其他语言2097152K 64bit IO Format: %lld题目描述 输入描述: 第一行一个正整数 n 第二行 n 个正整数 a1…an 第三行 n 个正…

【DP】【树状数组】免费馅饼(luogu 7302/金牌导航 数据结构优化DP-4)

正题 luogu 7302 金牌导航 数据结构优化DP-4 题目大意 在坐标轴上会出现n个金币&#xff0c;第i个金币tit_iti​时在wiw_iwi​出现&#xff08;只出现一个单位时间&#xff09;&#xff0c;价值为sis_isi​&#xff0c;当你tit_iti​时在wiw_iwi​&#xff0c;就能获得该金币…

Codeforces Round #666 (Div. 2)

哎太菜了就做出2个题掉了19分~~ A - Juggling Letters 统计一下每个字母出现的次数&#xff0c;由于最后要平均分配到每个数组中那么每个字母出现次数应该是n的倍数 #define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0) #include<string> #include<iost…

C# 函数式编程:LINQ

一直以来&#xff0c;我以为 LINQ 是专门用来对不同数据源进行查询的工具&#xff0c;直到我看了这篇十多年前的文章&#xff0c;才发现 LINQ 的功能远不止 Query。这篇文章的内容比较高级&#xff0c;主要写了用 C# 3.0 推出的 LINQ 语法实现了一套“解析器组合子&#xff08;…

【DP】【树状数组】方伯伯的玉米田/优美玉米(luogu 3287/金牌导航 数据结构优化DP-5)

正题 luogu 3287 金牌导航 数据结构优化DP-5 题目大意 有n个玉米&#xff0c;给出高度&#xff0c;你可以选择一个区间&#xff0c;使这个区间的玉米高度1&#xff0c;你可以进行k次这样的操作&#xff0c;查询你操作完后最长不下降子序列最大值 代码 对于选择区间[l,r]&…

2020牛客暑期多校训练营(第六场)

2020牛客暑期多校训练营&#xff08;第六场&#xff09; 额&#xff0c;睡了一下午&#xff0c;直接错过了比赛。。。 文章目录A African Sort题意&#xff1a;题解&#xff1a;代码&#xff1a;B Binary VectorC Combination of Physics and Maths题意&#xff1a;题解&#x…

P4001-[ICPC-Beijing 2006]狼抓兔子【对偶图】

正题 题目链接:https://www.luogu.com.cn/problem/P4001 题目大意 给出一个类似于 的网格图&#xff0c;求起点到终点的最小割。 解题思路 最小割直接跑网络流&#xff0c;然后发现dinicdinicdinic都过不了。&#xff08;好像加点玄学优化就能过&#xff09; 然后上点科技…

私有云方案——利用阿里云云解析实现DDNS

各位都是程序员&#xff0c;工作中是不是遇到个类似情况。在家里研究的一些开源代码或写的一些demo或试验代码&#xff0c;在工作中正好需要参考一下&#xff0c;但是在家里的电脑上。虽然这些都可以用云盘/网盘之类的来完成&#xff0c;源代码也可以托管到源码平台。但是这些都…

Namomo Fish(Easy) Round 1

C - Number 题目链接 做的时候就感觉是预处理aia_iai​变成每个数的步数&#xff0c;然后枚举最终变成的数。不过感觉dist[][]数组开不了那么大&#xff0c;赛后正解真的是这样于是就用map试了一下AC了 #define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0) #inclu…

纪中游记(7.11~7.22)

Day 0 早上 早上十点多从家里出发&#xff0c;坐了一个多小时的车&#xff0c;到广州&#xff0c;路上因为过于无聊&#xff0c;然后直接小颓了一波 中午 到了广州&#xff0c;找大哥出来吃了个饭&#xff08;牛扒直接嗦死&#xff09; 下午 然后又坐车到中山&#xff0c…