这次C题难得太突然,搞得博主有点手足无措,最后Rating掉了1分……(博主很菜)
赛时AC:A,B,C。
好,不说废话,直接上题解。
目录
A - ^{-1}
B - Playing Cards Validation
C - Ladder Takahashi
A - ^{-1}
A - ^{-1}AtCoder is a programming contest site for anyone from beginners to experts. We hold weekly programming contests online.https://atcoder.jp/contests/abc277/tasks/abc277_a不知道题目名称是什么意思,什么负不负一的,还异或?
题目大意:有一个数n和1~n的一组排列p,问x出现在第几位(下标从1开始)。
题目思路:这个好像没什么要解释的……直接上代码吧。
1
2
3
4
5
6
7
8
9
10
11
12
13
14#include<bits/stdc++.h> using namespace std; int main(){ cin.tie(0); ios::sync_with_stdio(0); int p[110],n,k; cin>>n>>k; for(int i=1;i<=n;i++){ int x; cin>>x; p[x]=i; } cout<<p[k]; return 0; } //ACplease!!!
B - Playing Cards Validation
B - Playing Cards ValidationAtCoder is a programming contest site for anyone from beginners to experts. We hold weekly programming contests online.https://atcoder.jp/contests/abc277/tasks/abc277_b虽然题目描述里没有明说,但是是人都能看出来这道题讲的是风靡全球的扑克牌……
题目大意:你有n个字符串,每个字符串长度为2,由大写英文字母和数字组成。第i个字符串是Si。
确定是否满足以下三个条件。
・对于每个字符串,第一个字符是H、D、C和S之一。
・对于每个字符串,第二个字符是A、2、3、4、5、6、7、8、9、T、J、Q、K之一。
・所有字符串都是互相不同的。
题目思路:set判是否重复,然后判断每一个字符是否满足条件。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33#include<bits/stdc++.h> using namespace std; bool colour(char c){ if(c=='H'||c=='D'||c=='C'||c=='S') return 1; else return 0; } bool number(char c){ if(c=='A'||c=='2'||c=='3'||c=='4'||c=='5'||c=='6'||c=='7'||c=='8'||c=='9'||c=='T'||c=='J'||c=='Q'||c=='K') return 1; else return 0; } int main(){ cin.tie(0); ios::sync_with_stdio(0); string s[60]; int n; cin>>n; set<string>se; for(int i=1;i<=n;i++){ cin>>s[i]; se.insert(s[i]); } if(n!=(int)se.size()) puts("No"); else{ for(int i=1;i<=n;i++){ if(!(colour(s[i][0])&&number(s[i][1]))){ puts("No"); return 0; } } puts("Yes"); } return 0; } //ACplease!!!
C - Ladder Takahashi
C - Ladder TakahashiAtCoder is a programming contest site for anyone from beginners to experts. We hold weekly programming contests online.https://atcoder.jp/contests/abc277/tasks/abc277_c看了题干,我的困惑是:
1.你确定有楼这么高吗?
2.就算有梯子,跨度这么大的楼层高桥有力气爬上去吗?
不管了,编程题一般都很离谱,完美脱离现实。
题目大意:有n个梯子,每个梯子从a到b,可以向上或向下走。没有梯子则不能走。现在高桥在1楼,请问他最高能爬到几楼。
题目思路:简单BFS。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35#include<bits/stdc++.h> using namespace std; int n,ans=1; map<int,vector<int> >a; map<int,bool>vis; queue<int>q; void bfs(){ q.push(1); vis[1]=1; while(!q.empty()){ if(q.empty()) break; int now=q.front(); q.pop(); ans=max(ans,now); for(int i=0;i<(int)a[now].size();i++) if(vis[a[now][i]]!=1){ vis[a[now][i]]=1; q.push(a[now][i]); } } return; } int main(){ cin.tie(0); ios::sync_with_stdio(0); cin>>n; for(int i=0;i<n;i++){ int x,y; cin>>x>>y; a[x].push_back(y); a[y].push_back(x); } bfs(); cout<<ans; return 0; } //ACplease!!!
感谢大家的阅读,下次比赛继续努力!
最后
以上就是无奈丝袜最近收集整理的关于Daiwa Securities Co. Ltd. Programming Contest 2022 Autumn (AtCoder Beginner Contest 277) A~C题详细讲解A - ^{-1}B - Playing Cards ValidationC - Ladder Takahashi的全部内容,更多相关Daiwa内容请搜索靠谱客的其他文章。
发表评论 取消回复