PAT甲级1154

从底盘到算法:开源扫地机器人完整方案技术拆解 移动机器人本质上是一套感知-决策-执行闭环系统,扫地机器人正是这种架构最典型的消费级落地载体。在机器人开发中,SLAM与传感器融合是决定自主定位导航精度的核心环节——通过多传感器时间同步与数据校准,让机器人同时完成地图构建与自身定位。开源硬件社区里,真正将底盘结构、电机控制、建图算法与上位机全部打通的完整方案并不多见;一套高质量的扫地机器人开源方案,能够帮助开发者绕开重复造轮子的过程,直接聚焦路径规划与运动控制的工程化验证。从高校竞赛到低成本底盘验证,这类方案都提供了一条从原理到实践的快速通道。通过拆解完整 阅读详情

PAT甲级1154

题目大意:给出n个顶点,m条边。接下来给出k组数据,问每组数据是否能构成彩色图,要求任意两个相连的顶点颜色不能相同。如果不能输出No,否则输出一共多少种颜色。
这里后两个测试点超时,一开始以为是set问题,后来发现这题用邻接表数据依然会很大,改成储存边即可。尽量不要额外开辟一个visit判断多少种颜色,数据int范围会越界。

#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#define MAXN 10005
using namespace std;

struct edge{
	int v1,v2;
};
int n,m;
vector<edge> e;
bool isColoring(vector<int> q){
	for(int i=0;i<e.size();i++){
		if(q[e[i].v1]==q[e[i].v2]) return false;
	}
	return true;
}
int main(){
	int vertex1,vertex2;
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d%d",&vertex1,&vertex2);
		edge tmpedge;
		tmpedge.v1=vertex1,tmpedge.v2=vertex2;
		e.push_back(tmpedge);
	}
	int k,tmpv;
	scanf("%d",&k);
	vector<int> query;
	set<int> color;
	for(int i=0;i<k;i++){
		color.clear();
		query.clear();
		for(int j=0;j<n;j++){
			scanf("%d",&tmpv);
			color.insert(tmpv);
			query.push_back(tmpv);
		}
		if(isColoring(query)) printf("%d-coloring\n",color.size());
		else printf("No\n");
	}
	system("pause");
	return 0;
}

电力抄表协议DL/T645和698.45到底有啥区别?一张图帮你选对协议 本文深入对比了电力抄表协议DL/T645和DL/T698.45的技术差异,从协议架构、报文结构、功能覆盖到实施成本进行全面分析。通过实际案例和数据,揭示698.45协议在通信效率、业务扩展性和长期成本上的优势,并提供清晰的选型决策流程图,帮助工程师根据具体需求选择最适合的电力抄表协议。 阅读详情

相关推荐

Anolis OS 23实战:5分钟搞定AI环境配置(含NVIDIA驱动一键安装)

本文详细介绍了如何在Anolis OS 23上快速配置AI开发环境,包括NVIDIA驱动的一键安装和TensorFlow、PyTorch等AI框架的部署。通过智能硬件适配引擎和优化后的二进制包,用户可在5分钟内完成传统需要数小时的配置工作,显著提升AI项目开发效率。

weixin_30335575的博客 535

第十天PAT-A1154 Vertex Coloring邻接表做法

A1154 Description: 求所给颜色序列是否为所给图的合适着色,即相邻两点颜色不同。 注意边数为零的情况 邻接表存储法模板见A1003 Emergency "总结记忆"部分 #include<iostream> #include<stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> #include<algorithm> #include<m

giggle66的博客 168

SAP 运费处理方式

从直接的处理方式上看,情况1/2/3可以将运费记账到物料成本中,但情况4/5/6是直接记账到成本对象中,具体是要体现在损益表中,还是要结转到物料成本中,可依据业务要求进行好处理。如果体现在损益表中,不需要多过多额外的操作,如果要体现在物料成本中心,则需要再进行一系列的处理,最终将金额结转到物料成本中。因为在创建采购订单时不知道具体运费,可以不维护运费,只需要维护材料价格。:创建采购订单时,运费是由供应商承担,很多时候是包含在材料报价中,这种情况不需要专门针对运费进行处理,材料价格中已包含运费。

weixin_44506537的博客 3371

PAT A1154

很简单的一道题,前期卡在了第二个段错误 后来发现颜色的编号是int型范围,果然把10010大小的bool哈希数字换成了set 此处还是有点紧张,因为担心set超时,不过还好过了 #include &lt;iostream&gt; #include &lt;map&gt; #include &lt;string&gt; #include &lt;cstring&gt; #include &lt;ve...

qq_39034011的博客 204

ESP32开发环境避坑指南:用Thonny烧录MicroPython固件时常见的5个错误及解决方法

本文针对ESP32开发新手,详细解析了使用Thonny IDE烧录MicroPython固件时最常见的5个错误及其解决方案。内容涵盖驱动安装、端口识别、固件烧录失败、版本兼容性、连接不稳定以及文件系统操作异常等核心痛点,并提供硬件层面的深度排查指南,帮助开发者高效搭建稳定的ESP32开发环境。

weixin_29189003的博客 407

语言模型推理能力与计算表达力深度解析

语言模型的推理能力本质上是一种知识迁移与泛化应用的过程,其核心在于Transformer架构中的自注意力机制和前馈网络的协同作用。计算表达力作为衡量模型能力的关键指标,涉及函数逼近、组合泛化和上下文理解等多个维度。随着模型规模的扩大,涌现能力现象揭示了参数规模与推理能力之间的非线性关系。在实际应用中,通过提示工程和微调策略可以有效激活和优化模型的推理表现。当前研究正探索模块化架构和世界模型整合等方向,以突破长程推理和因果关系建模等前沿挑战。本文深入探讨了语言模型推理泛化的技术原理与实践方法,为理解计算表达力

weixin_42521032的博客 341

PAT A1154 2019.08.14 【自定义图判断 map】

1154Vertex Coloring(25分) Aproper vertex coloringis a labeling of the graph's vertices with colors such that no two vertices sharing the same edge have the same color. A coloring using at mostk...

一个非计算机专业的 博客 231

UE实现贴地线(SurfaceLine)效果

UnrealEngine实现贴地线效果

专注GIS开发 4572

pat a 1154

感觉最近写这些东西有些束手束脚的,害怕用的算法不好而超时 #include <iostream> #include <vector> #include <set> using namespace std; const int maxv=10010; vector<int> g[maxv]; int color[maxv]; int main(){...

blxl313的博客 179

H3C BGP联盟实验

bgp,bgp联盟,bgp公认团体属性,

一只懒羊羊 969

YOLOv8独家原创改进:原创自研 | 自研独家创新DSAM注意力 ,基于BiLevelRoutingAttention注意力升级

提出新颖的注意力DSAM(Deformable Bi-level SpatialAttention Module),创新度极佳,适合科研创新,效果秒杀CBAM,Channel Attention+Spartial Attention升级为新颖的Deformable Bi-level Attention+Spartial Attention

①答疑群聊服务;②YOLO大模型知识问答系统;③计算机视觉论文生成智能体; 1512

pat甲级学习笔记1154

PAT甲级 1154 Vertex Coloring 参考代码by:柳婼 https://blog.youkuaiyun.com/liuchuo/article/details/84973030 A proper vertex coloring is a labeling of the graph’s vertices with colors such that no two vertices sharing the same edge have the same color. A coloring using at

illusion_ist的博客 327

leetcode134 加油站

题目如下 在一条环路上有 N 个加油站,其中第 i 个加油站有汽油 gas[i] 升。 你有一辆油箱容量无限的的汽车,从第 i 个加油站开往第 i+1 个加油站需要消耗汽油 cost[i] 升。你从其中的一个加油站出发,开始时油箱为空。 如果你可以绕环路行驶一周,则返回出发时加油站的编号,否则返回 -1。 说明: 如果题目有解,该答案即为唯一答案。 输入数组均为非空数组,且长度相同。 输...

ayang818 's blog 233

PAT【甲级】1154

题目链接:PAT【甲级】1154 题目简述:给定几条由vertex vertes格式表示的边,再给定一组数字,表示节点的颜色。来让判断这个图是不是满足各条边的两端节点颜色都不同,如果满足则输出这个图总共使用了几种颜色,否则输出“No”。 #include<bits/stdc++.h> using namespace std; int v_color[10001]; unordered_map<int, pair<int, int>> graph; unordered_m

qq_41375322的博客 184

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

18年冬季第三题 PAT甲级 1154 Vertex Coloring (25分) 两种思路

题目来源:https://pintia.cn/problem-sets/994805342720868352/problems/1071785301894295552 备考汇总贴:2020年3月PAT甲级满分必备刷题技巧 Aproper vertex coloringis a labeling of the graph's vertices with colors such that no...

qiiingc的解题记录 1038

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

PAT 甲级 1154 Vertex Coloring (25分)

1154 Vertex Coloring

Droke_Zhou的博客 291

PAT甲级 1154 Vertex Coloring(25)

这道25分题闹麻了,大水题,根本不用建图+dfs,直接存边比较就行了。但是java会超时,c++可以过。

Hackeryuan的博客 350

【PAT甲级题解记录】1154 Vertex Coloring (25 分)

问题描述 给定一个图的节点和边,以及每一个点的颜色,如果有临接点颜色相同输出No,否则输出不同的颜色数量。 解题思路 方法一:遍历边即可,如果当成无向图遍历一遍会每个边多遍历一遍,但是时间足够就这么简单的写吧。 方法二:除了直接遍历边,还可以用dfs来判断。

retr0的博客 145

PAT甲级1154 Vertex Coloring :[C++题解]图论、模拟、结构体存边

刷题

阿正的梦工坊 521

pat 甲级1154 Vertex Coloring (25分)

文章目录pat 甲级1154 Vertex Coloring (25分) pat 甲级1154 Vertex Coloring (25分) 代码:(水题,不分析了哈:) #include <iostream> #include <vector> #include <set> using namespace std; struct edge { int vertex1,vertex2; }temp; vector<edge> g; int main()

qq_44992782的博客 261

PAT 甲级 1154  Vertex Coloring

1154Vertex Coloring(25 point(s)) Aproper vertex coloringis a labeling of the graph's vertices with colors such that no two vertices sharing the same edge have the same color. A coloring using at ...

漫浸天空的雨色的备忘录~ 856

PAT(甲级)1154

题意:给出一张图,每个点有一个颜色,一条边上的两个点要求不同色,同色输出No,满足条件输出一共使用了多少颜色。 题解:暴力搜索每一条边判断。 注意点:一道简单的图的遍历题目,没有大的坑点。 code in view #include<bits/stdc++.h> using namespace std; const int maxn=1e4+10; int n,m,k; vector&...

qq_42836930的博客 252

【PAT甲级 - C++题解】1154 Vertex Coloring

📣专栏定位:为想考甲级PAT的小伙伴整理常考算法题解,祝大家都能取得满分!

Newin2020的博客 956

PAT 甲级 1154 Vertex Coloring

https://pintia.cn/problem-sets/994805342720868352/problems/1071785301894295552 Aproper vertex coloringis a labeling of the graph's vertices with colors such that no two vertices sharing the same...

weixin_30472035的博客 146

PAT甲级 1154 Vertex Coloring

1153 Decode Registration Card of PAT 25 分题目分析代码 题目 题目描述 分析 题目大意:给出一组学生的准考证号和成绩,准考证号包含了等级(乙甲顶),考场号,日期,和个人编号信息,并有三种查询方式 查询一:给出考试等级,找出该等级的考生,按照成绩降序,准考证升序排序 查询二:给出考场号,统计该考场的考生数量和总得分 查询三:给出考试日期,查询改日期下所有考场的...

weixin_41699413的博客 179
上一篇: PAT甲级1153
下一篇: 记录一下python学习中的问题
zerohawk
博客等级 码龄8年 3粉丝 78原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值