CodeForces Round #145(234D) - Cinema

     算出每个演出的可能最少喜欢演员人数MIN,和可能最多喜欢演员人数MAX...对于一个演出来说若其MIN不小于其他所有演出的MAX..则其为surely be the favourite...若其MAX不大于其他所有演出的MIN,则其为won't surely be the favourite...都不满足..只能是can either be favourite, or not favourite


Program:

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#define ll long long
using namespace std;
struct node
{
    int MAX,MIN;
}c[105];
int m,n,num,k,x,a[105];
bool f[105];
char s[25];
int main()
{  
    freopen("input.txt","r",stdin);    freopen("output.txt","w",stdout);
    int i,j,n1,n2,nn,h;
    while (~scanf("%d%d",&m,&k))
    {
          memset(f,false,sizeof(f));
          for (i=1;i<=k;i++) 
          {
                 scanf("%d",&j);
                 f[j]=true;
          }
          scanf("%d",&n);
          for (i=1;i<=n;i++)
          {
                 scanf("%s%d",s,&num);
                 n1=k,n2=m-k,h=nn=0;
                 for (j=1;j<=num;j++) 
                 {
                        scanf("%d",&x); 
                        if (!x) nn++;
                           else 
                             if (f[x]) h++,n1--;
                                else n2--;
                 }
                 if (n1>=nn) c[i].MAX=h+nn;
                        else c[i].MAX=h+n1;
                 if (n2>=nn) c[i].MIN=h;
                        else c[i].MIN=h+nn-n2;
          } 
          for (i=1;i<=n;i++)
          { 
                 for (j=1;j<=n;j++)
                 if (j!=i && c[j].MAX>c[i].MIN) break;
                 if (j>n) printf("0\n");
                     else
                     {
                           for (j=1;j<=n;j++)
                           if (j!=i && c[j].MIN>c[i].MAX) break; 
                           if (j<=n) printf("1\n");
                                else printf("2\n");
                     }
          }
    }
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值