1149 Dangerous Goods Packaging (25 point(s))

【PAT (Advanced Level) Practice】1149 Dangerous Goods Packaging (25 分) 1149 Dangerous Goods Packaging (25 分) When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves in serious trouble. For example, oxidizing agent (氧化剂) must not be packe 阅读详情

1149 Dangerous Goods Packaging (25 point(s))

When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves in serious trouble. For example, oxidizing agent (氧化剂) must not be packed with flammable liquid (易燃液体), or it can cause explosion.

Now you are given a long list of incompatible goods, and several lists of goods to be shipped. You are supposed to tell if all the goods in a list can be packed into the same container.

Input Specification:

Each input file contains one test case. For each case, the first line gives two positive integers: N (≤10​4​​), the number of pairs of incompatible goods, and M (≤100), the number of lists of goods to be shipped.

Then two blocks follow. The first block contains N pairs of incompatible goods, each pair occupies a line; and the second one contains M lists of goods to be shipped, each list occupies a line in the following format:

K G[1] G[2] ... G[K]

where K (≤1,000) is the number of goods and G[i]'s are the IDs of the goods. To make it simple, each good is represented by a 5-digit ID number. All the numbers in a line are separated by spaces.

Output Specification:

For each shipping list, print in a line Yes if there are no incompatible goods in the list, or No if not.

Sample Input:

6 3
20001 20002
20003 20004
20005 20006
20003 20001
20005 20004
20004 20006
4 00001 20004 00002 20003
5 98823 20002 20003 20006 10010
3 12345 67890 23333

Sample Output:

No
Yes
Yes

STL的使用(pair/set),也可以用哈希代替set。

#include<iostream>
#include<vector>
#include<cstring>
#include<set>
using namespace std;
set<int> s;
vector<pair<int,int> > v;
int main(void){
	int N,M,k,a,b;cin>>N>>M;
	for(int i=0;i<N;i++){
		cin>>a>>b;
		v.push_back(pair<int,int>(a,b));
	}
	while(M--){
		cin>>k;
		s.clear();
		while(k--){
			cin>>a;
			s.insert(a);
		}
		bool isOk = true;
		for(auto it:v){
			if(s.find(it.first)!=s.end()&&s.find(it.second)!=s.end()){
				isOk = false;break;
			}
		}
		if(isOk) puts("Yes");
		else puts("No");
	}
	return 0;
}

 

hcaptcha-challenger:基于本地AI模型自动破解验证码的工程实践 验证码作为区分人类与机器的经典安全机制,其核心原理是通过图像识别、行为分析等交互式挑战来阻挡自动化程序。传统绕过方法依赖第三方打码平台或脚本,存在成本高、稳定性差的问题。随着多模态大语言模型和计算机视觉技术的发展,本地化AI求解成为新的技术方向,它通过集成YOLO、ResNet等模型,在本地完成图像语义理解,实现了高隐私、低成本、可进化的验证码自动化解决方案。这种范式尤其适用于需要大规模稳定处理网页交互的场景,如电商数据采集和社交媒体管理。hcaptcha-challenger项目正是这一理念的工程实践,它 阅读详情

相关推荐

STM32F407单一定时器输出4路不同频率及占空比的PWM波

STM32F407单一定时器输出4路不同频率及占空比的PWM波

qq_43868701的博客 4920

【PAT甲级 - C++题解】1149 Dangerous Goods Packaging

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

Newin2020的博客 622

别再到处找模型了!手把手教你用Xinference+Docker部署本地私有大模型(Llama2/Qwen实战)

本文详细介绍了如何使用Xinference和Docker部署本地私有化大模型(如Llama2/Qwen),涵盖硬件配置、模型管理、Docker部署及性能优化等关键步骤。通过实战案例,帮助开发者快速构建企业级AI推理服务,确保数据安全与高效运行。

weixin_28683065的博客 232

PAT 1149 Dangerous Goods Packaging

原题链接:1149 Dangerous Goods Packaging (25分) 关键词:hash、枚举 题目大意: 给定两两互斥的物品列表,判断给定的物品清单是否满足不存在互斥物品。

cwtnice的博客 266

【一文搞懂几种常用推荐算法】

协同过滤:适合用户-物品交互数据丰富的场景。矩阵分解:能处理稀疏数据,适合显式评分预测。基于内容:依赖物品特征,解决冷启动问题。NMF:适用于非负数据(如点击率、购买记录)。根据实际需求选择算法,或结合多种方法构建混合推荐系统。

专注技术的博主 2638

C#与发那科机器人通信实战:从SDK配置到机械臂控制

本文详细介绍了如何使用C#与发那科机器人进行通信,从SDK配置到机械臂控制的完整实战流程。内容包括环境准备、通信连接建立、机械臂运动控制、异常处理与状态监控,以及高级功能实战,帮助开发者快速掌握工业机器人编程技术。

weixin_42524276的博客 459

PAT 甲级 1149  Dangerous Goods Packaging

1149Dangerous Goods Packaging(25 point(s)) When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves in serio...

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

深度排查:网讯网卡WX1860AL4千兆网口降速百兆的硬件陷阱

本文详细剖析了网讯网卡WX1860AL4千兆网口降速至百兆的硬件故障排查过程。通过分析千兆以太网硬件原理,提供从网线、供电到PCB走线、焊接残留的标准化检修流程,并分享两种典型硬件陷阱(线序错误与焊锡短路)的实战修复案例,为硬件工程师解决类似传输速率问题提供系统性的诊断思路与方法。

a3b4c5的博客 1113

1149 Dangerous Goods Packaging (25分)

题目 When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves in serious trouble. For example, oxidizing agent (氧...

小白的博客 445

USB接口ESD防护设计实战:从金属外壳到信号线的完整避坑指南

本文深入探讨USB接口ESD防护设计的实战要点,聚焦金属外壳作为ESD能量泄放关键通道的处理策略。文章详细解析了从外壳接地路径控制、信号线TVS管选型与布局,到PCB分区及电源线滤波等完整设计流程,旨在帮助硬件工程师构建系统级防护,避免常见设计误区,确保产品通过严苛的静电测试。

k8l9m0n的博客 482

Windows 11 - 打开操作安全中心提示 “需要使用新应用以打开此 Windowsdefender 链接“ 解决方案(电脑更新了 Win11 系统版本后,想关闭病毒防护盾牌的时候提示打不开)

Windows 11 - 打开操作安全中心提示 "需要使用新应用以打开此 Windowsdefender 链接" 解决方案(电脑更新了 Win11 系统版本后,想关闭病毒防护盾牌的时候提示打不开),当您点击任务栏上要关闭安全中心防护设置时,这种情况打不开怎么解决,怎么办,Windows安全中心,病毒和威胁保护,账户保护,防火墙和网络保护,设备安全性。

🏆 前端领域优质创作者 1万+

1149 Dangerous Goods Packaging (25point(s))

When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves in serious trouble. For example, oxidizing agent (氧化剂) must not be packed with flammable liquid (易燃液体), or it

void 184

① Django手把手从零开发个人博客-前言

手把手教你从零开始玩转手把手教你从零开始玩转Django,全面学习并了解django的运行机制、开发全流程及线上部署。Django,全面学习并了解django的运行机制、开发全流程及线上部署。 专栏介绍 本套教程遵循Django的设计思想,开门见山,快速切入主题,拒绝拖沓,在实战中学习每一个知识点,提高学习的趣味性以及个人成就感,并且能快速将所学运用到实际项目中。 将从零手把手带着你一步步完成博客的每一个功能,通过实现博客文章列表页、文章详情页、作者页面等功能来学习和了解django的视图查询模块相关知.

轻编程的博客 515

1149 Dangerous Goods Packaging (25 point(s))

1149 Dangerous Goods Packaging (25 point(s)) When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves in serious trouble. For example, oxidizing agent (氧化剂) must not b

TypicalSpider的博客 145

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

1149 Dangerous Goods Packaging (25point(s)) - C语言 PAT 甲级

* 利用二分查找,没有不相容物品即可装箱

有三只土豆 317

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

1149 Dangerous Goods Packaging(25 point(s))

1149 Dangerous Goods Packaging(25 point(s))

张蔡辉 292

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

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

PAT A1149 Dangerous Goods Packaging (25point(s)) (Multimap)

PAT A1149 Dangerous Goods Packaging 思路 1:hash表 遍历时,将该所有与该元素相冲的标记出来 之后如果遍历到那个元素,输出No,如果遍历完一组数据,输出Yes code 1: #include <iostream> #include <vector> #include <algorithm> using na...

qq_42347617的博客 198

PAT_甲级_1149 Dangerous Goods Packaging (25point(s)) (C++)【STL应用】

目录 1,题目描述 题目大意 2,思路 3,AC代码 4,解题过程 1,题目描述 Sample Input: 6 3 20001 20002 20003 20004 20005 20006 20003 20001 20005 20004 20004 20006 4 00001 20004 00002 20003 5 98823 20002 20003 20006 10010 ...

&再见萤火虫&的博客 385

PAT(A) 1149 Dangerous Goods Packaging (25 point(s))

#include<bits/stdc++.h> using namespace std; vector<int> icp[100010]; bool judge(vector<int> v){ int n = v.size(); for(int i = 0; i < n; i++) for(int j = i+1; j < n; j++) if(find(icp[v[i]].begin(), icp[

Anpotan的博客 101

1149 Dangerous Goods Packaging (25 分)

1149 Dangerous Goods Packaging (25 分) When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves in serious trou...

L_Aster的专栏 684

PAT 1149 Dangerous Goods Packaging(25 分)- 甲级

When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves in serious trouble. For example, oxidizing agent (氧化剂)...

柳婼 の blog 3563

1149 Dangerous Goods Packaging

描述 When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves in serious trouble. For example, oxidizing a...

测试 384

1149 Dangerous Goods Packaging (25 分)

1149 Dangerous Goods Packaging (25 分) When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves in serious troub...

92377 311

1149 Dangerous Goods Packaging (25 分)

1149Dangerous Goods Packaging(25分) When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves in serious trou...

请赐教 315

pat甲级1149 1149 Dangerous Goods Packaging (25分)

pat甲级1149 1149 Dangerous Goods Packaging (25分) note:非并查集,水题,10分钟小代码 代码: #include <iostream> #include <vector> #include <unordered_map> using namespace std;

qq_44992782的博客 188
上一篇: 1148 Werewolf - Simple Version (20 point(s))
下一篇: 1150 Travelling Salesman Problem (25 point(s))
coderwait
博客等级 码龄9年 20粉丝 210原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值