POJ 2664
#include<iostream>
#include<stdio.h>
#include<algorithm>
#define MAXN 105
using namespace std; int a[MAXN];
bool Binarry_search(int a[],int size,int num); bool binarry_search(int a[],int num,int low,int high);
int main()
{
//freopen("acm.acm","r",stdin);
int cous;
int cate;
int c;
int r;
int i;
int j;
int tem;
int test;
bool boo;
while(scanf("%d%d",&cous,&cate),cous)
{
boo = false;
test = ;
for(i = ; i < cous; ++ i)
{
scanf("%d",&a[i]);
}
sort(a,a+cous);
for(i = ;i < cate; ++ i)
{
scanf("%d%d",&c,&r);
for(j = ; j < c; ++ j)
{
scanf("%d",&tem);
if(binarry_search(a,tem,,cous-))
++ test;
}
if(test < r)
{
boo = true;
}
test = ;
}
if(!boo)
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
}
} ////////////////////////////////////////////////////////////////////////////////////////
//· Binarry_search_algorithm ·//
////////////////////////////////////////////////////////////////////////////////////////
bool Binarry_search(int a[],int size,int num)
{
int i;
int low = ;
int high = size -;
int mid;
while(low <= high)
{
mid = (low + high)/;
if(num < a[mid])
{
high = mid - ;
}
else if(num > a[mid])
{
low = mid + ;
}
else
return true;
}
return false;
} bool binarry_search(int a[],int num,int low,int high)
{
int mid;
mid = (low + high)/;
if(low > high)
return false;
if(num < a[mid])
binarry_search(a,num,low,mid - );
else if(num > a[mid])
binarry_search(a,num,mid + ,high);
else
return true; }
POJ 2664的更多相关文章
- POJ 2664 Prerequisites?(简单题)
[题意简述]:k:已经选择的科目数:m:选择的科目类别:c:能够选择的科目数.r:要求最少选择的科目数量 在输入的k和m以下的一行是选择的科目号. 比如: 3 2 //3是他选择了3科.2表示选择了两 ...
- 【POJ - 2664】Prerequisites? (排序+查找)
Prerequisites? 原文是English,这里直接就写中文吧 题意简述 k:已经选择的科目数:m:选择的科目类别:c:能够选择的科目数.r:要求最少选择的科目数量 在输入的k和m以下的一行是 ...
- POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
- POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22286 ...
- POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法
Flip Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37427 Accepted: 16288 Descr ...
- POJ 3254. Corn Fields 状态压缩DP (入门级)
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9806 Accepted: 5185 Descr ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
- POJ 2255. Tree Recovery
Tree Recovery Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11939 Accepted: 7493 De ...
随机推荐
- main.cpp
/*main.cpp * *The starting point of the network simulator *-Include all network header files *-initi ...
- 深度优先搜索DFS和广度优先搜索BFS
DFS简介 深度优先搜索,一般会设置一个数组visited记录每个顶点的访问状态,初始状态图中所有顶点均未被访问,从某个未被访问过的顶点开始按照某个原则一直往深处访问,访问的过程中随时更新数组visi ...
- myeclipse安装svn方法汇总
myeclipse安装svn方法汇总 博客分类: eclipse MyEclipse6.5安装SVN插件,掌握了几种方法,本节就像大家介绍一下MyEclipse6.5安装SVN插件的三种方法,看完 ...
- ubuntu 设置DNS
sudo vi /etc/resolv.conf #加入nameserver 114.114.114.114
- 比较jquery中的after(),append(),appendTo()方法
html页面: <p id="myp1">我的兴趣爱好是:</p> <button id="b1">after函数</ ...
- Flex布局(CSS Flexbox)
参考:Flex 布局语法教程 Flex布局是什么? Flex是Flexible Box的缩写,意为”弹性布局”,用来为盒状模型提供最大的灵活性. 任何一个容器都可以指定为Flex布局 注意:设为Fle ...
- poj 1125 Stockbroker Grapevine(最短路径)
Description Stockbrokers are known to overreact to rumours. You have been contracted to develop a me ...
- WebGIS实现在线要素编辑之ArcGIS Server 发布Feature Service 过程解析
WebGIS实现在线要素编辑之ArcGIS Server 发布Feature Service 过程解析 FeatureService也称要素服务,其最大的好处就是支持在线要素编辑,并将编辑同步更新到后 ...
- 20145232 韩文浩 《Java程序设计》第7周学习总结
教材学习内容总结 就目前来说,即使标注为GMT(格林威治时间),实际上谈到的时间指的是UTC时间. 秒的单位定义时基于TAI.也就是铯原子辐射的振动次数. UTC考虑了地球自转越来越慢而有闰秒修正,确 ...
- input.php
<?php /** * */ class Input { function get($index = NULL, $xss_clean = FALSE) { if($index == NULL ...