[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)