Poj 2664 prerequisites? (Simple question)

Source: Internet
Author: User

[Description]: K: number of selected subjects; M: selected subject category; C: number of available subjects; R: Minimum number of subjects required

The row below K and m is the selected account number.

For example:

3 2 // 3. He chose three subjects, 2 indicates that two categories are selected: 0123 9876 2222 // This is the specific 3 Subject no. 2 1 8888 2222 // 2 indicates that there are two subjects in this category: 8888 and. 2222, then select at least one of the two categories, 3 2 9876 2222 7654 // This is the second category, with the same meaning as above.

Code:

//208K 500Ms#include<iostream>using namespace std;int k,m,c,r;int a[100];int b[100];int main(){while(1){int flag = 0;cin>>k;if(k == 0) break;cin>>m;for(int i = 0;i<k;i++)cin>>a[i];while(m--){int count = 0;cin>>c>>r;for(int i = 0;i<c;i++)cin>>b[i];for(int i = 0;i<k;i++){for(int j = 0;j<c;j++){if(a[i] == b[j])count++;}}if(count < r){flag = 1;}}if(flag)cout<<"no"<<endl;elsecout<<"yes"<<endl;}return 0;}


Poj 2664 prerequisites? (Simple question)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.