2025年睿抗机器人开发者大赛CAIP-编程技能赛(省赛)
·
当时比赛的时候主要卡到第三题了,一直都是13分,所以最后两个题没怎么看,今天在做的时候,借鉴了一下其他博主(弥彦_)的思路(第五题自己没有手敲,大家有需求直接去这个博主的文章上看)
评价:本人蓝桥杯国二,个人觉得今年睿抗题目偏算法较少,模拟较多,2h时间比较紧,很考验大家的题目理解能力、代码纠错能力等。但比蓝桥杯友好的是机制,因为是实时给分,建议大家还是把近几年的题目都做一下,重点提升一下代码纠错能力,要不然很有可能会在考场卡在一个题目上面。
一、RC-u1 早鸟价

输入样例:
6
6 20 2000
6 20 1800
6 20 1700
6 21 1800
7 11 2000
7 12 2500
输出样例:
^_^
Ok!
Need more!
Need more!
Ok!
Too late!
1.1 解题思路:
首先明确t次循环,然后对于每一个缴费信息,先判断日期,在哪一个范围之内,然后具体根据它的金额判断输出即可。
1.2代码示例:
#include<bits/stdc++.h>
using namespace std;
void solve()
{
int a,b,c;
cin>>a>>b>>c;
if(a<6||a==6&&b<=20)
{
if(c>1800)
{
cout<<"^_^"<<endl;
}
else if(c==1800)
{
cout<<"Ok!"<<endl;
}
else{
cout<<"Need more!"<<endl;
}
}
else if(a>7||a==7&&b>=12)
{
cout<<"Too late!"<<endl;
}
else
{
if(c>2000)
{
cout<<"^_^"<<endl;
}
else if(c==2000)
{
cout<<"Ok!"<<endl;
}
else{
cout<<"Need more!"<<endl;
}
}
}
int main()
{
int t;
cin>>t;
while(t--)
{
solve();
}
return 0;
}
二、RC-u2 谁进线下了?

输入样例:
3
6 67
1 25
7 4
19 3
4 11
2 20
6 8
6 20
1 25
7 4
19 3
4 11
2 20
6 8
6 51
1 19
4 16
1 28
5 9
1 29
16 0
输出样例:
0 0
0 1
1 1
2.1 解题思路:
跟第一题一样,纯模拟题。在遍历n局的排名和积分的时候,记录第一名的局数并且把n局的积分加到一起,最后进行判断第一名的局数是否达到50%、总分是否超过第二名50分及以上。
2.2代码示例:
#include<bits/stdc++.h>
using namespace std;
void solve()
{
int n,s;
int sum=0;//总分
cin>>n>>s;
int t=0;//第一名的局数
for(int i=0;i<n;i++)
{
int a,b;
cin>>a>>b;
if(a==1)t++;
sum+=b;
}
double c=1.0*t/n;
if(c>=0.5){
cout<<1<<" ";
}
else{
cout<<0<<" ";
}
if(sum>=s+50){
cout<<1<<endl;
}
else{
cout<<0<<endl;
}
}
int main()
{
int t;
cin>>t;
while(t--)
{
solve();
}
return 0;
}
三、RC-u3 点格棋



输入样例1:
3 3 12
0 1 1 1 2
1 3 3 3 2
0 1 2 1 3
1 3 1 3 2
0 1 1 2 1
1 2 3 3 3
0 2 1 2 2
1 1 2 2 2
1 2 2 2 3
0 1 3 2 3
0 2 2 3 2
0 2 1 3 1
输出样例1:
-1
0 3
输入样例2:
3 3 16
1 1 1 1 2
0 1 1 1 2
1 3 3 2 2
1 3 3 3 2
0 1 2 1 3
1 3 1 3 2
0 1 1 2 1
1 2 3 3 3
0 2 1 2 2
1 2 1 2 2
1 1 2 2 2
0 2 2 2 3
1 2 2 2 3
0 1 3 2 3
0 2 2 3 2
0 2 1 3 1
输出样例2:
1 3 10 12
0 3
3.1 解题思路:
大模拟题:

我们可以用两个数组,分别存横线段和竖线段是否已经画过
3.2代码示例:
#include<bits/stdc++.h>
using namespace std;
int n,m,s;
vector<int>a(10000);//横线段
vector<int>b(10000);//竖线段
int gain(int a,int b,int sign)//传入点坐标,根据sign获得相应的横线段或者竖线段
{
if(sign==0)return (a-1)*(m-1)+b;//横线段
else return (b-1)*(n-1)+a;//竖线段
}
int judge(int x,int y,int sign)//传入点坐标,根据sign求出加上当前线段后能组成多少个小正方形
{
int sum=0;
if(sign==0)//当前走的是横线段
{
if(x>1)
{
int a1,a2,a3,a4;
a1=gain(x-1,y,0);
a2=gain(x-1,y,1);
a3=gain(x,y,0);
a4=gain(x-1,y+1,1);
if(a[a1]&&b[a2]&&a[a3]&&b[a4])
{
sum++;
}
}
if(x<n)
{
int a1,a2,a3,a4;
a1=gain(x,y,0);
a2=gain(x,y,1);
a3=gain(x+1,y,0);
a4=gain(x,y+1,1);
if(a[a1]&&b[a2]&&a[a3]&&b[a4])
{
sum++;
}
}
}
else//竖线段
{
if(y>1)
{
int a1,a2,a3,a4;
a1=gain(x,y-1,0);
a2=gain(x,y-1,1);
a3=gain(x+1,y-1,0);
a4=gain(x,y,1);
if(a[a1]&&b[a2]&&a[a3]&&b[a4])
{
sum++;
}
}
if(y<n)
{
int a1,a2,a3,a4;
a1=gain(x,y,0);
a2=gain(x,y,1);
a3=gain(x+1,y,0);
a4=gain(x,y+1,1);
if(a[a1]&&b[a2]&&a[a3]&&b[a4])
{
sum++;
}
}
}
return sum;
}
int main()
{
cin>>n>>m>>s;
int a_score=0;
int b_score=0;
int now=0;//0代表是小A的回合,1代表是小B的回合
a.assign(a.size(), 0);
b.assign(b.size(), 0);
vector<int>v;//存错误步骤
for(int i=1;i<=s;i++)
{
int temp,startx,starty,endx,endy;
cin>>temp>>startx>>starty>>endx>>endy;
if(now!=temp)//回合归属人错误
{
v.push_back(i);
continue;
}
//错误步骤(出界)
if(startx>n||startx<1||endx>n||endx<1||starty>m||starty<1||endy>m||endy<1)
{
v.push_back(i);
continue;
}
if(abs(startx-endx)+abs(starty-endy)!=1)
{
v.push_back(i);
continue;
}
else if(startx==endx)//横线段
{
int location=gain(startx,min(starty,endy),0);
if(a[location]==1)//此线段已经被走过
{
v.push_back(i);
continue;
}
else
{
a[location]=1;
//得分
int score=judge(startx,min(starty,endy),0);
if(score==0)
{
now=!now;
}
else
{
if(now==0)a_score+=score;
else b_score+=score;
}
}
}
else//竖线段
{
int location=gain(min(startx,endx),starty,1);
if(b[location]==1)//此线段已经被走过
{
v.push_back(i);
continue;
}
else
{
b[location]=1;
//得分
int score=judge(min(startx,endx),starty,1);
if(score==0)
{
now=!now;
}
else
{
if(now==0)a_score+=score;
else b_score+=score;
}
}
}
}
if(v.size()==0)
{
cout<<-1<<endl;
}
else
{
int nn=v.size();
for(int i=0;i<nn;i++)
{
cout<<v[i];
if(i!=nn-1)cout<<" ";
}
cout<<endl;
}
if(a_score>b_score)
{
cout<<0<<" "<<a_score;
}
else
{
cout<<1<<" "<<b_score;
}
}
四、RC-u4 Tree Tree 的

输入样例:
2
5 6
1 2
2 3
3 1
1 4
4 5
5 4
5 5
1 2
2 3
3 4
4 5
5 1
输出样例:
3 2
5 2
4.1 解题思路:
考察树、图的知识点
根据题目意思得,G'是个环或者是两个点的一条边,因为只有这种情况,才能满足它的两个条件。找环我们直接用dfs即可。
4.2代码示例:
#include<bits/stdc++.h>
using namespace std;
vector<int>sign(11);
vector<int>v[11];
int ans1,ans2;
void dfs(int now,int sum,int begin)
{
for(auto num:v[now])
{
if(sign[num])
{
continue;
}
if(num==begin)
{
if(sum>ans1)
{
ans2=ans1;
ans1=sum;
}
else if(sum>ans2&&ans1>sum)
{
ans2=sum;
}
}
sign[num]=1;
dfs(num,sum+1,begin);
sign[num]=0;
}
}
void solve()
{
int n,m;
cin>>n>>m;
for(int i=0;i<11;i++)v[i].clear();
for(int i=0;i<m;i++)
{
int a,b;
cin>>a>>b;
v[a].push_back(b);
v[b].push_back(a);
}
for(int i=1;i<11;i++)sign[i]=0;
ans1=1;
ans2=0;
for(int i=1;i<=n;i++)
{
dfs(i,1,i);//当前节点为i,共1个节点,这条路径开始节点为i
}
cout<<ans1<<" "<<ans2<<endl;
}
int main()
{
int t;
cin>>t;
while(t--)
{
solve();
}
return 0;
}
五、RC-u4 Tree Tree 的

输入样例:
2
5 6
1 2
2 3
3 1
1 4
4 5
5 4
5 5
1 2
2 3
3 4
4 5
5 1
输出样例:
3 2
5 2
5.1 解题思路:
2025 睿抗机器人开发者大赛CAIP-编程技能赛-本科组(省赛)题解_2025睿抗省赛题解-CSDN博客
逆向BFS
5.2代码示例:
#include<bits/stdc++.h>
using namespace std;
vector<int>sign(11);
vector<int>v[11];
int ans1,ans2;
void dfs(int now,int sum,int begin)
{
for(auto num:v[now])
{
if(sign[num])
{
continue;
}
if(num==begin)
{
if(sum>ans1)
{
ans2=ans1;
ans1=sum;
}
else if(sum>ans2&&ans1>sum)
{
ans2=sum;
}
}
sign[num]=1;
dfs(num,sum+1,begin);
sign[num]=0;
}
}
void solve()
{
int n,m;
cin>>n>>m;
for(int i=0;i<11;i++)v[i].clear();
for(int i=0;i<m;i++)
{
int a,b;
cin>>a>>b;
v[a].push_back(b);
v[b].push_back(a);
}
for(int i=1;i<11;i++)sign[i]=0;
ans1=1;
ans2=0;
for(int i=1;i<=n;i++)
{
dfs(i,1,i);//当前节点为i,共1个节点,这条路径开始节点为i
}
cout<<ans1<<" "<<ans2<<endl;
}
int main()
{
int t;
cin>>t;
while(t--)
{
solve();
}
return 0;
}
更多推荐

所有评论(0)