Daiwa Securities Co. Ltd. Programming Contest 2022 Autumn (AtCoder Beginner Contest 277) A~C题详细讲解

这次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开始)。

题目思路:这个好像没什么要解释的……直接上代码吧。

#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判是否重复,然后判断每一个字符是否满足条件。

#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。

#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!!!

感谢大家的阅读,下次比赛继续努力!

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值