博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
GT and set
阅读量:4477 次
发布时间:2019-06-08

本文共 1813 字,大约阅读时间需要 6 分钟。

GT and set

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 605    Accepted Submission(s): 211

Problem Description
You are given 
N sets.The ith set has Ai numbers.
You should divide the sets into L parts.
And each part should have at least one number in common.
If there is at least one solution,print YES,otherwise print NO.
 

 

Input
In the first line there is the testcase 
T (T20)
For each teatcase:
In the first line there are two numbers N and L.
In the next N lines,each line describe a set.
The first number is Ai,and then there are Ai distict numbers stand for the elements int the set.
The numbers in the set are all positive numbers and they're all not bigger than 300.
1N301L51Ai101LN
You'd better print the enter in the last line when you hack others.
You'd better not print space in the last of each line when you hack others.
 

 

Output
For each test print 
YES or NO
 

 

Sample Input
2 2 1 1 1 1 2 3 2 3 1 2 3 3 4 5 6 3 2 5 6
 

 

Sample Output
NO YES
Hint
For the second test,there are three sets:{1,2,3},{4,5,6},{2,5,6} You are asked to divide into two parts. One possible solution is to put the second and the third sets into the same part,and put the first in the other part. The second part and the third part have same number 6. Another solution is to put the first and the third sets into the same part,and put the second in the other part.

 

#include
using namespace std;typedef long long ll;const int maxn = 2e5 + 50;int T,n,l,vis[1008];vector
e[maxn];inline bool check(int cur){ for(register int i=0;i
n)return true; if(check(cur))return solve(cur+1,part); if(part>=l)return false; for(register int i=0;i

 

转载于:https://www.cnblogs.com/czy-power/p/11488263.html

你可能感兴趣的文章
JQuery学习系列篇(一)
查看>>
Centos7 minimal 系列之rabbitmq安装(八)
查看>>
英语语法(2)----点破主谓宾系表三大句型
查看>>
html如何与cgi数据交换,HTML网页与CGI之间通信的 实例分析
查看>>
html如何调用flash插件,htmlflash播放器插件如何播放 网页播放器flash插件怎么解决...
查看>>
mysql数据在html上面显示不出来的,HTML表格不能正确显示MySQL数据
查看>>
数据包和html,数据包和数据报有何区别?
查看>>
jq 异步调用一个html,聊聊如何将jQuery的$.ajax()用于异步HTTP请求
查看>>
html导出excel多sheet,js 导出多sheet表格
查看>>
html日期函数,我所见过的最简短、最灵活的javascript日期转字符串工具函数
查看>>
flann matlab,FLANN 快速的(近似)最近邻开源库
查看>>
pmta linux视频,PowerMTA (PMTA) 的安装和设置方法 – 黄忠 – 博客
查看>>
2016秋季C语言程序设计试题,2016c语言程序设计模拟试题
查看>>
C语言编程初体验 作文,C语言作文件操常用代码
查看>>
rar for android去广告,安卓解压神器RAR v5.30.39 去广告版
查看>>
android p什么变化,Android P预览版,这些调整和变化最值得关注
查看>>
android 7.0宽度432,全球最小的4G手机,比手掌还小,安卓7.0
查看>>
android fragmentstatepageradapter框架,Android FragmentStatePagerAdapter
查看>>
html自适应meta标签,自适应布局meta标签中viewport、content、width、initial-scale、minimum-scale、maximum-scale总结...
查看>>
html怎么加入编辑器,HTML 编辑器
查看>>