1350. Canteen Timus Online Judge





问题:主要是要能看懂题意...题很简单... 顺便感谢下群里大佬的翻译
题目是这个意思
每顿饭有M种食物,输入的前N种食物代表着可能包含的食物有哪些

然后输入一个k,剩下有k+1个部分

每部分代表着第i个学生吃了含有这些食物的饭就会中毒

最后一行那个数是M

第一个学生吃了之后没问题,求其他学生吃过后会不会中毒

分析:其实只需要拿每个人的危险食物和第一个人的危险物品做对比就行...就这一点




 dangerous to eat in a canteen — you may be poisoned by a not fresh food. One may fall into a coma because of the canteen’s chicken and the other feels OK. And vice

versa. The food is cooked from M different food stuffs. There are N different food stuffs in the menu but not all of them are at the distribution. Assume that K + 1 students eat the food and we know for each student what products may poison him. The first student eats and he is not poisoned. How the dinner affect on the other students?
Input
The first line contains an integer N (1 ≤  N ≤ 100). The next N lines contain the food stuffs names — non-empty sequences of Latin letters and digits with length not more than 40 symbols. Then there is a number K (1 ≤  K ≤ 100) and K + 1 blocks describing the menu food stuffs dangerous for the canteen visitors afterwards. The i th block starts with a line with an integer Ni — an amount of dangerous food stuffs and then there are Ni lines with the names of those dangerous stuffs (0 ≤  Ni ≤  N). The first block describes the food stuffs dangerous for the first student, the next K blocks — for the rest ones. The input ends with the line containing an integer M (0 ≤  M ≤  N).
Output
K lines — the i th line should contain:
  • YES, if the dinner is harmless for the (i + 1)st student,
  • NO, if among the food stuffs there is a dangerous one for the (i + 1)st student,
  • MAYBE, if there may be different situations under the given conditions.
Example

7
Rafinad
Kefir
Pastila
Smetana
Chokolade
Kljukva
Imbir
3
3
Rafinad
Kefir
Imbir
1
Rafinad
3
Kefir
Kljukva
Smetana
2
Imbir
Smetana
3

output

YES
NO
MAYBE
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
using namespace std;

int main(){
	vector<string> all_s;
	vector<string> no_danger;
	int all_num,no_dangernum,k,m;
	string temp;
	scanf("%d",&all_num);	
	for(int i=0;i<all_num;i++){
		cin>>temp;
		all_s.insert(all_s.end(),temp); //总的食物列表 
	}
	scanf("%d",&k);
	scanf("%d",&no_dangernum);
	for(int ii=0;ii<no_dangernum;ii++){
		cin>>temp;
		no_danger.insert(no_danger.end(),temp); //好的食物(没添加的食物) 
	} 
	int n[105],n1[105],doubtnum=all_num-no_dangernum;
	for(int i=0;i<k;i++){
		scanf("%d",&n[i]);
		n1[i]=n[i];
		for(int j=0;j<n[i];j++){
			string t;
			cin>>t;
			vector<string>::iterator iter=std::find(no_danger.begin(),no_danger.end(),t);
			if(iter!=no_danger.end()) 
				n1[i]--;
		}
	}
	scanf("%d",&m);
	for(int i=0;i<k;i++){
		if(n1[i]==0){
			printf("YES\n");
			continue;
		} 
		else if(n1[i]<=doubtnum-m) printf("MAYBE\n");
		else printf("NO\n");
	}
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值