2024年睿抗机器人开发者大赛(RAICOM)国赛题解

news2024/9/20 9:30:19

目录

RC-u1 大家一起查作弊   分数 15

RC-u2 谁进线下了?II     分数 20

RC-u3 势均力敌     分数 25

RC-u4 City 不 City     分数 30

RC-u5 贪心消消乐    分数 30


RC-u1 大家一起查作弊   分数 15

简单模拟题,对于多行读入使用while(getline(cin,s))即可

// 数学公式要变形
// 莫急莫急先读题
#include <bits/stdc++.h>
using namespace std;
#define lowbit(x) (x&(-x))
#define endl "\n"
#define ios ios::sync_with_stdio(0); cin.tie(0),cout.tie(0);
#define LF(x)   fixed<<setprecision(x)// c++ 保留小数
#define den(a) cout << #a << " = " << a << "\n";
#define deg(a) cout << #a << " = " << a << " ";
typedef long long LL;
typedef pair<int, int> PII;
const int N=1000010,M=1010,INF=0x3f3f3f3f,mod=1e9+7;
const double pai=acos(-1.0);// pai
map<int,int> mp;
int t,n,m;

//是不是关键字
bool check(char x){
	if('A'<=x and x<='Z') return true;
	if('a'<=x and x<='z') return true;
	if(isdigit(x)) return true;
	return false;
}
//可疑分数计算
int get(string s){
	int big = 0, small = 0, sz = 0;
	for(auto&x:s){
		if('A'<=x and x<='Z') big = 1;
		if('a'<=x and x<='z') small = 1;
		if(isdigit(x)) sz = 1;
	}
	if(big and small and sz) return 5;
	if(sz and (big or small)) return 3;
	if(big and small) return 1;
	return 0;
}
void solve(){
    
    int sum = 0,len = 0, cnt = 0;
    string s;
    while(getline(cin,s)){
    	string now;
    	for(auto&v:s)
    		if(check(v)) now += v;
    		else{
    			if(!now.empty()){
    				sum += get(now);
    				len += now.size();
    				cnt++;
    			}
    			now.clear();
    		}
        // 可能最后还有东西
    	if(!now.empty()){
    		sum += get(now);
    		len += now.size();
    		cnt++;
    	}
    }
    cout << sum << endl;
    cout << len << ' ' << cnt << endl;
    return ;
}
signed main ()
{
    ios// 不能有printf puts scanf
    int t=1;
    while(t--){
    	 solve();
    }
}

RC-u2 谁进线下了?II     分数 20

简单模拟,按照题目意思模拟即可

// 数学公式要变形
// 莫急莫急先读题
#include <bits/stdc++.h>
using namespace std;
#define lowbit(x) (x&(-x))
#define endl "\n"
#define ios ios::sync_with_stdio(0); cin.tie(0),cout.tie(0);
#define LF(x)   fixed<<setprecision(x)// c++ 保留小数
#define den(a) cout << #a << " = " << a << "\n";
#define deg(a) cout << #a << " = " << a << " ";
typedef long long LL;
typedef pair<int, int> PII;
const int N=1000010,M=1010,INF=0x3f3f3f3f,mod=1e9+7;
const double pai=acos(-1.0);// pai
map<int,int> mp;
int t,n,m;
int d[30] = {0,25,21,18,16};
bool st[N];
int w[N];

struct code{
	int id,x;
	bool operator<(const code&t)const{
		if(x==t.x) return id<t.id;
		return x>t.x;
	}
}e[N];

void solve(){
    
	for(int i=5;i<=20;i++) d[i] = 20 - i;
	
	cin>>n;
	while(n--){
		m = 20;
		while(m--){
			int x,r; cin>>x>>r;
			w[x] += d[r];
			st[x] = true;
		}
	}    
	n = 30;
	for(int i=1;i<=n;i++) e[i]={i,w[i]};
	sort(e+1,e+1+n);
	
	for(int i=1;i<=n;i++){
		auto [id,x] = e[i];
		if(!st[id]) continue;
		cout << id << ' ' << x << endl;
	}
	cout << endl;
    return ;
}
signed main ()
{
    ios// 不能有printf puts scanf
    int t=1;
    while(t--){
    	 solve();
    }
}

RC-u3 势均力敌     分数 25

按照题目直接暴力枚举所有情况使用全排列 + 二进制枚举

时间复杂度大致如下 同时不会跑满所以可以通过

2^{24} + C^{12}_{24} * 24

// 数学公式要变形
// 莫急莫急先读题
#include <bits/stdc++.h>
using namespace std;
#define lowbit(x) (x&(-x))
#define endl "\n"
#define ios ios::sync_with_stdio(0); cin.tie(0),cout.tie(0);
#define LF(x)   fixed<<setprecision(x)// c++ 保留小数
#define den(a) cout << #a << " = " << a << "\n";
#define deg(a) cout << #a << " = " << a << " ";
typedef long long LL;
typedef pair<int, int> PII;
const int N=1000010,M=1010,INF=0x3f3f3f3f,mod=1e9+7;
const double pai=acos(-1.0);// pai
map<int,int> mp;
int t,n,m;
int a[N],p[N];

void solve(){
    
    cin>>n;
    for(int i=1;i<=n;i++){
    	cin>>a[i];
    	p[i] = i;
    }
    vector<int> v;
    int sum = 0;
    do{
    	int ans = 0;
    	for(int i=1;i<=n;i++) ans = ans * 10 + a[p[i]];
    	v.push_back(ans);
    	sum += ans;
    }while(next_permutation(p+1,p+1+n));
    
    m = v.size();
   
    

    for(int i=0;i<(1<<m);i++){
    	if(__builtin_popcount(i)!=m/2) continue;
    	int now = 0;
    	vector<int> ans;
    	for(int j=0;j<m;j++){
    		if(i>>j&1){
				ans.push_back(v[j]);
				now += v[j];	
    		}
    	}
    	if(now==sum/2){
    		for(auto&v:ans) cout << v << endl;
    		cout << endl;
    		return ;
    	}
    }
    return ;
}
signed main ()
{
    ios// 不能有printf puts scanf
    int t=1;
    while(t--){
    	 solve();
    }
}

RC-u4 City 不 City     分数 30

典型的分层图,一个城市有多个状态,跑一遍djikstra即可,注意本题是计算途经城市的hot值,所以初始状态是 d[s][0]  = 0,在可以抵达t的时候来判断即可

// 数学公式要变形
// 莫急莫急先读题
#include <bits/stdc++.h>
using namespace std;
#define lowbit(x) (x&(-x))
#define endl "\n"
#define ios ios::sync_with_stdio(0); cin.tie(0),cout.tie(0);
#define LF(x)   fixed<<setprecision(x)// c++ 保留小数
#define den(a) cout << #a << " = " << a << "\n";
#define deg(a) cout << #a << " = " << a << " ";
typedef long long LL;
typedef pair<int, int> PII;
typedef array<int,3> ar3;
const int N=1000010,M=1010,INF=0x3f3f3f3f,mod=1e9+7;
const double pai=acos(-1.0);// pai
map<int,int> mp;
int n,m,s,t;
int h[M];
vector<PII> g[M];
int d[M][110];

void solve(){
    
    cin>>n>>m>>s>>t;
    
    for(int i=1;i<=n;i++) cin>>h[i];
    
    while(m--){
    	int a,b,c; cin>>a>>b>>c;
    	g[a].push_back({b,c});
    	g[b].push_back({a,c});
    }
    
    int ans = 2e9,pos = -1;
    auto dijkstra = [&](){
    	memset(d,0x3f,sizeof d);
    	priority_queue<ar3,vector<ar3>,greater<ar3>> q;
    	d[s][0] = 0, q.push({0,s,0});
    	while(!q.empty()){
    		auto [cost,u,hot] = q.top(); q.pop();
    		for(auto&[v,w]:g[u]){
    			int ne = max(hot,h[v]);
    			if(v==t){
    				if(cost+w<ans){
    					ans = cost + w;
    					pos = hot;
    				}
    				else if(cost+w==ans and hot<pos){
    					pos = hot;
    				}
    			}
    			if(d[v][ne]>cost+w){
    				d[v][ne] = cost + w;
    				q.push({cost+w,v,ne});
    			}
    		}
    	}
    };
    dijkstra();
    if(pos==-1) cout << "Impossible" << endl;
    else cout << ans << ' ' << pos << endl;
    
    return ;
}
signed main ()
{
    ios// 不能有printf puts scanf
    int t=1;
    while(t--){
    	 solve();
    }
}

RC-u5 贪心消消乐    分数 30

贪心模拟,每次都暴力的找到可以选取的最大矩阵即可,然后模拟下降,没有找到正解,这里贴一下别人的x*(n^4)比较暴力的做法,赛时通过了

#include <bits/stdc++.h>

using namespace std;
using i64 = long long;

constexpr int inf = 5E6;

void solve() {
	int n;
	cin >> n;
	
	vector<vector<int>> g(n, vector<int>(n, 0));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> g[i][j];
			if (g[i][j] == 0) {
				g[i][j] = -inf;
			}
		}
	}
	
	vector<vector<i64>> sum(n + 1, vector<i64>(n + 1, 0));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			sum[i + 1][j + 1] = sum[i + 1][j] + sum[i][j + 1] - sum[i][j] + g[i][j];
		}
	}
	
	i64 tot = 0;
	while (1) {
		i64 hi = 0;
		int a, b, c, d;
		for (int x1 = 0; x1 < n; x1++) {
			for (int y1 = 0; y1 < n; y1++) {
				for (int x2 = x1; x2 < n; x2++) {
					for (int y2 = y1; y2 < n; y2++) {
						if (g[y2][x2] == -inf) {
							break;
						}
						i64 cur = sum[y2 + 1][x2 + 1] - sum[y2 + 1][x1] - sum[y1][x2 + 1] + sum[y1][x1];
						if (cur > hi) {
							hi = cur;
							a = x1;
							b = y1;
							c = x2;
							d = y2;
						}
						if (cur < 0) {
							break;
						}
					}
				}
			}
		}
		if (hi <= 0) {
			break;
		}
		
		tot += hi;
		cout << "(" << a + 1 << ", " << b + 1 << ") (" << c + 1 << ", " << d + 1 << ") " << hi << "\n";
		
		int o = d - b + 1;
		for (int x = a; x <= c; x++) {
			for (int y = d; y >= 0; y--) {
				if (y >= o) {
					g[y][x] = g[y - o][x];
				} else {
					g[y][x] = -inf;
				}
			}
		}
		for (int i = 0; i <= n; i++) {
			fill(sum[i].begin(), sum[i].end(), 0);
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				sum[i + 1][j + 1] = sum[i + 1][j] + sum[i][j + 1] - sum[i][j] + g[i][j];
			}
		}
	}
	cout << tot << "\n";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int T = 1;
//	cin >> T;

	while (T--) {
		solve();
	}

	return 0;
}

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

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

相关文章

切割 Nginx 日志

目录 方式一&#xff1a;自定义脚本 方式二&#xff1a;logrotate crontab 讲解 centos 容器安装 crontab centos 容器 systemctl 命令执行异常 切割理由&#xff1a;假设一个网站访问量特别大&#xff0c;每天 access_log 文件有 2 个 G&#xff0c;如果想从文件中查找…

基于QCustomPlot实现色条(ColorBar)

一、简介 通过QCustomPlot实现ColorBar&#xff0c;直观显示各个位置的异常情况。实现效果如下&#xff0c; 二、源码 CPColorBar.hpp // CPColorBar.hpp #pragma once #include "qcustomplot.h"#include <QHash>class QCP_LIB_DECL CPColorBarData { pub…

使用 MRI 构建的大脑连接网络预测帕金森病萎缩进展模式| 文献速递-基于深度学习的乳房、前列腺疾病诊断系统

Title 题目 Brain Connectivity Networks Constructed Using MRI for Predicting Patterns of Atrophy Progression in Parkinson Disease 使用 MRI 构建的大脑连接网络预测帕金森病萎缩进展模式 Background 背景 Whether connectome mapping of structural and across …

全志T527-TP9930-Camera

一、简介 1、TP9930 TP9930 驱动模块主要实现将 4 路的 Camera 的数据转换为 BT656/BT1120 数据&#xff0c;从而实现在 T527 端来对数据进行处理和送显。 2、BT656/BT1120简介 BT656主要是针对PAL/NTSC等标清视频。随着高清视频的发展需要&#xff0c;又推出了BT1120标准&…

AI + Coding:可以有多少种玩法?

在当今快速发展的科技时代&#xff0c;人工智能&#xff08;AI&#xff09;和编程已经成为不可分割的两大领域。AI赋予了计算机更多的智能&#xff0c;使其能够处理复杂的数据、执行高级任务&#xff0c;而编程是实现这一切的基础。当AI与编程结合在一起时&#xff0c;会带来无…

图片懒加载与预加载(原生)

1、懒加载。 <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><meta name"viewport" content"widthdevice-width, initial-scale1.0"><title>Document</title> </head>…

【开端】JAVA Mono<Void>向前端返回没有登陆或登录超时 暂无权限访问信息组装

一、绪论 JAVA接口返回信息ServerHttpResponse response 等登录接口token过期时需要给前端返回相关状态码和状态信息 二、Mono<Void>向前端返回没有登陆或登录超时 暂无权限访问信息组装 返回Mono对象 public abstract class Mono<T> implements CorePublisher…

2024最新Mysql事务原理与优化最佳实践

概述 我们的数据库一般都会并发执行多个事务&#xff0c;多个事务可能会并发的对相同的一批数据进行增删改查操作&#xff0c;可能就会导致我们说的脏写、脏读、不可重复读、幻读这些问题。 这些问题的本质都是数据库的多事务并发问题&#xff0c;为了解决多事务并发问题&…

在java中通过subString方法来截取字符串中的文本

1、subString&#xff08;&#xff09;常规用法可以通过下标来进行获取&#xff0c;在java中是从0开始&#xff0c;前包括后不包括。 String str “Hello Java World!”; 用法一: substring(int beginIndex) 返回从起始位置&#xff08;beginIndex&#xff09;至字符串末尾…

供应链库存管理面临什么问题?全面解析安全库存和周转库存!

在当今这个快速变化的商业世界中&#xff0c;供应链管理已成为企业获取竞争优势的核心领域。库存管理&#xff0c;作为供应链中的关键环节&#xff0c;直接关系到企业的成本控制、客户服务水平以及市场响应速度。然而&#xff0c;面对市场竞争的加剧和客户需求的多变&#xff0…

事务性邮件调用接口如何配置灵活调用策略?

事务性邮件调用接口性能怎么优化&#xff1f;如何使用接口调用&#xff1f; 如何配置灵活调用策略&#xff0c;不仅可以提升邮件发送的效率和可靠性&#xff0c;还能增强用户体验。AokSend将详细介绍事务性邮件调用接口的配置方法和策略&#xff0c;以便企业在实际应用中取得最…

深度学习读书笔记(1)--机器学习、人工智能、深度学习的关系

声明&#xff1a;本文章是根据网上资料&#xff0c;加上自己整理和理解而成&#xff0c;仅为记录自己学习的点点滴滴。可能有错误&#xff0c;欢迎大家指正。 阅读的书籍主要为《UnderstandingDeepLearning》《动手学深度学习》 1956 年提出 AI 概念&#xff0c;短短3年后&…

【初阶数据结构题目】14.随机链表的复制

随机链表的复制 点击链接做题 思路&#xff1a; 浅拷贝&#xff1a;拷贝值 深拷贝&#xff1a;拷贝空间 在原链表的基础上继续复制链表置random指针复制链表和原链表断开 代码&#xff1a; /*** Definition for a Node.* struct Node {* int val;* struct Node *next…

【开发踩坑】windows查看jvm gc信息

windows查看jvm gc信息 EZ 找出java进程PID 控制面板----搜索任务管理器---- 任务管理器----搜索 java----详细信息 这里PID是4856 cmd jstat gc面板 reference&#xff1a; jstat命令

【Redis】缓存三大问题与缓存一致性问题

缓存三大问题 缓存穿透 缓存穿透是指用户查询的数据在缓存和数据库中都不存在&#xff0c;导致每次请求都会直接落到数据库上&#xff0c;增加数据库负载。 解决方案 1&#xff09;参数校验 一些不合法的参数请求直接抛出异常信息返回给客户端。比如查询的数据库 id 不能小于…

【letcod-c++】128.最长连续序列

一、题目 二、分析 第一想法是像“242字母异位词”那样用哈希数组&#xff0c;但是这个数组元素的范围比较广&#xff0c;元素又比较分散&#xff0c;用数组太浪费空间&#xff0c;不合适。 于是考虑用哈希set(unordered_set),这个时候忽然想到前几天学习到set它能自动排序且自…

MySQL笔记(九):存储引擎

一、介绍 二、演示 Memory的使用场景&#xff1a; 例如网吧&#xff0c;用户再次上线时会更新状态 #表类型和存储引擎-- 查看所有的存储引擎SHOW ENGINES; -- 1、innodb 支持事务&#xff0c;外键&#xff0c;行级锁-- 2、myisam CREATE TABLE t31(id INT,name VARCHAR(32)) …

十二、享元模式

文章目录 1 基本介绍2 案例2.1 Digit 接口2.2 Color 枚举2.3 BigDigit 类2.4 DigitFactory 类2.5 Client 类2.6 Client 类的测试结果2.7 总结 3 各角色之间的关系3.1 角色3.1.1 Flyweight ( 抽象享元 )3.1.2 ConcreteFlyweight ( 具体享元 )3.1.3 UnsharedFlyweight ( 非享元 )…

2023/8/7 英语每日一段

There is unintended usefulness in this gentle enforcement of empathy. A mere news story makes it easy to deploy the defensive mechanism social scientists call “othering” which dismisses the victim, freak or dupe. But if it’s someone you have watched or …

文件上传绕过最新版安全狗

本文来源无问社区&#xff0c;更多实战内容&#xff0c;渗透思路可前往查看http://www.wwlib.cn/index.php/artread/artid/9960.html http分块传输绕过 http分块传输⼀直是⼀个很经典的绕过⽅式&#xff0c;只是在近⼏年分块传输⼀直被卡的很死&#xff0c;很多waf都开始加 …