当前位置:网站首页>2021 RoboCom 世界机器人开发者大赛-高职组(决赛)
2021 RoboCom 世界机器人开发者大赛-高职组(决赛)
2022-08-05 11:50:00 【Alan_Lowe】
2021 RoboCom 世界机器人开发者大赛-高职组(决赛)
1.小偷踩点

AC代码
#include<bits/stdc++.h>
using namespace std;
int n,m;
vector<string> v;
string s;
vector<int> row;
set<int> r;
vector<int> row_value[15];
signed main(){
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>n>>m;
cin.get();
for (int i = 1; i <= n; ++i) {
getline(cin,s);
v.push_back(s);
}
for (int i = 0; i < m; ++i) {
int a;cin>>a;
row.push_back(a);
r.insert(a);
}
for (int i : row) {
for (int j = 0; j < 10; ++j) {
int b;cin>>b;
row_value[i].push_back(b);
}
}
int k;cin>>k;
while(k--){
int a,b,c;cin>>a;b = a / 10;c = a % 10;
if (r.count(b) == 0){
cout<<"?\n";
continue;
}
if (row_value[b][c] == -1){
cout<<"?\n";
continue;
}
cout<<v[row_value[b][c] - 1]<<"\n";
}
return 0;
}
2.盲盒包装流水线

AC代码
#include<bits/stdc++.h>
using namespace std;
int n,s,a;
queue<string> q;
map<string,int> mp;
stack<int> sta;
signed main(){
cin>>n>>s;
for (int i = 0; i < n; ++i) {
string t;cin>>t;
q.push(t);
}
for (int i = 1; i <= n / s; ++i) {
for (int j = 1; j <= s; ++j) {
cin>>a;
sta.push(a);
}
for (int j = 1; j <= s; ++j) {
a = sta.top();sta.pop();
mp[q.front()] = a;q.pop();
}
}
int k;cin>>k;string t;
while (k--){
cin>>t;
if (mp[t])
cout<<mp[t]<<"\n";
else
cout<<"Wrong Number\n";
}
return 0;
}
3.到底爱不爱我

思路
看了样例说明就能知道了,这是一颗往上画的树,然后三种树枝就是逻辑与或非。
AC代码
#include<bits/stdc++.h>
using namespace std;
int n;
struct node{
int p,ls,rs;
} x[35];
bool note[35]; //标记以找到根节点
int now;string s;
bool dfs(int tree){
if (x[tree].p == 3){
if (x[tree].ls == 0)
return !(s[now++] - '0');
else
return !dfs(x[tree].ls);
}
else if (x[tree].p == 2){
if (x[tree].ls == 0 && x[tree].rs == 0){
bool f = (s[now] - '0') | (s[now + 1] - '0');
now += 2;
return f;
}
else if (x[tree].ls != 0 && x[tree].rs == 0){
bool f = dfs(x[tree].ls);
f = f | (s[now] - '0');
++now;
return f;
}
else if (x[tree].ls == 0 && x[tree].rs != 0){
bool f = (s[now] - '0');
++now;
f = f | dfs(x[tree].rs);
return f;
}
else{
bool f = dfs(x[tree].ls);
f = f | dfs(x[tree].rs);
return f;
}
}
else{
if (x[tree].ls == 0 && x[tree].rs == 0){
bool f = (s[now] - '0') & (s[now + 1] - '0');
now += 2;
return f;
}
else if (x[tree].ls != 0 && x[tree].rs == 0){
bool f = dfs(x[tree].ls);
f = f & s[now];
now += 1;
return f;
}
else if (x[tree].ls == 0 && x[tree].rs != 0){
bool f = s[now] - '0';
now += 1;
f = f & dfs(x[tree].rs);
return f;
}
else{
bool f = dfs(x[tree].ls);
f = f & dfs(x[tree].rs);
return f;
}
}
}
signed main(){
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int n;
cin>>n;
for (int i = 1; i <= n; ++i) {
cin>>x[i].p;
if (x[i].p == 3)
cin>>x[i].ls;
else
cin>>x[i].ls>>x[i].rs;
note[x[i].ls] = note[x[i].rs] = true;
}
int tree = -1;
for (int i = 1; i <= n; ++i) //找根
if (!note[i])
tree = i;
int k;cin>>k;
while (k--){
cin>>s;
now = 0;
if (dfs(tree))
cout<<"Ai\n";
else
cout<<"BuAi\n";
}
return 0;
}
4.皆大欢喜

思路
这个题目就是个dfs爆搜,然后加上剪枝就行了,但是这个题目我被vector卡了,不知道是剪枝没剪好还是什么。总之就是我要用一个vector赋值给另一个vector,这种操作比数组的memcpy更慢。。。。
这里把两种代码都贴一下吧,也有可能是剪枝没剪好,大家可以帮我看看。
25分vector
#include<bits/stdc++.h>
using namespace std;
int n,m;
int x[15][15];
bool vis[15];
vector<int> ans;
vector<int> f_ans;
void dfs(const vector<int>& vv){
for (int i = 1; i <= m; ++i) {
if (vis[i]) continue;
vector<int> v = vv;
bool f = true;
for (int j = 1; j <= n; ++j) {
if (x[i][j] == 1)
v[j] = 1;
else if (x[i][j] == -1)
v[j] = -1;
if (v[j] != 1)
f = false;
}
if (f){
f_ans.push_back(i);
if (ans.empty() || ans.size() > f_ans.size()){
ans = f_ans;
}
f_ans.pop_back();
return;
}
else{
vis[i] = true;
f_ans.push_back(i);
dfs(v);
f_ans.pop_back();
vis[i] = false;
}
}
}
signed main(){
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>n>>m;
vector<int> v(11,-1); //记录猫咪的状态
for (int i = 1; i <= m; ++i)
for (int j = 1; j <= n; ++j)
cin>>x[i][j];
dfs(v);
cout<<ans[0];
for (int i = 1; i < ans.size(); ++i) {
cout<<" "<<ans[i];
}
return 0;
}
30分数组
#include<bits/stdc++.h>
using namespace std;
int n,m;
int x[15][15];
bool vis[15];
int note[15];
int ans[15],l;
int f_ans[15],cnt;
void dfs(){
int note_note[15];
for (int i = 1; i <= m; ++i) {
if (vis[i]) continue;
memcpy(note_note,note,60);
bool f = true;
for (int j = 1; j <= n; ++j) {
if (x[i][j] == 1)
note[j] = 1;
else if (x[i][j] == -1)
note[j] = -1;
if (note[j] != 1)
f = false;
}
if (f){
f_ans[cnt++] = i;
if (l == 0 || l > cnt){
memcpy(ans,f_ans,60);
l = cnt;
}
cnt--;
return;
}
else{
vis[i] = true;
f_ans[cnt++] = i;
dfs();
cnt--;
vis[i] = false;
}
memcpy(note,note_note,60);
}
}
signed main(){
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>n>>m;
for (int i = 1; i <= n; ++i) note[i] = -1;
for (int i = 1; i <= m; ++i)
for (int j = 1; j <= n; ++j)
cin>>x[i][j];
dfs();
cout<<ans[0];
for (int i = 1; i < l; ++i) {
cout<<" "<<ans[i];
}
return 0;
}
边栏推荐
- 2022.08.03_每日一题
- Android development with Kotlin programming language three loop control
- D-Desthiobiotin-PEG4-Maleimide主要物理性质特点 !
- 【HMS core】【FAQ】Health Kit、Ads kit、push Kit典型问题合集5
- Qt::qcustomplot 和 qchart数据填充相关
- SonarQube即将亮相第十八届GOPS全球运维大会
- Hands-on Deep Learning_GoogLeNet / Inceptionv1v2v3v4
- I'm going crazy.Again A few days can not be A problem
- 数据治理体系演进简介
- swig 语法介绍
猜你喜欢

365 days challenge LeetCode1000 questions - Day 050 add a row to the binary tree binary tree

Official release 2022 Nanjing Zhibo Expo is scheduled to be held in Xinzhuang National Exhibition in October

Gao Zelong attended the Boao Global Tourism Ecology Conference to talk about Metaverse and Future Network Technology

深度学习(四)分析问题与调参 理论部分

Monthly observation of Internet medical field in June 2022

Letter from Silicon Valley: Act fast, Facebook, Quora and other successful "artifacts"!

高泽龙出席博鳌全球旅游生态大会 讲元宇宙与未来网络科技

2022年6月互联网医疗领域月度观察

基于NSQ搭建高可用分布式消息队列

内存问题难定位,那是因为你没用ASAN
随机推荐
前沿技术数字孪生如何应用在智慧城市上?
Mathcad 15.0软件安装包下载及安装教程
课表小程序使用攻略
手把手教你定位线上MySQL慢查询问题,包教包会
796. 子矩阵的和
常用的免费Api接口网址
shell编程流程控制练习
解决 cuDNN launch failure 错误
Apache APISIX Ingress v1.5-rc1 发布
【7.29-8.5】写作社区精彩技术博文回顾
Support Vector Machine SVM
isn't it?Is there anyone who can't locate the slow query problem of MySQL online?
PHP高级检索功能的实现以及动态拼接SQL
Keras 模型多输出 loss weight metrics 设置
623. Add a row to a binary tree: Simple binary tree traversal problems
【HMS core】【FAQ】Health Kit、Ads kit、push Kit典型问题合集5
Grid Infrastructure Installation Fails with Error
Can't get in to ask questions.I want to ask you a question about the return value (traversal of the graph), please give Xiaobai an answer.
普通二本毕业八年,京东就职两年、百度三年,分享大厂心得
Hands-on Deep Learning_GoogLeNet / Inceptionv1v2v3v4