PAT1073

#include <bits/stdc++.h>

using namespace std;

struct Node
{
    int full;
    set<char>ss;
    map<char,int>mp;
};
int N,M,K,t;
int Maxt = 0;
vector<Node>v;
map<char,int>mp;

//s1是学生的答案
int isContain(set<char>s1,set<char>s2)
{
    if(s1.size()>=s2.size()) return 0;
    for(auto it = s1.begin();it != s1.end();it++)
    {
        if(!s2.count(*it)) return 0;
    }
    return 1;
}

void addWrong(set<char>s1,set<char>s2,int t)
{
    for(auto it = s1.begin();it!=s1.end();it++)
    {
        if(!s2.count(*it))
        {
            v[t].mp[*it]++;
            Maxt = max(Maxt,v[t].mp[*it]);
        }
    }
    for(auto it = s2.begin();it!=s2.end();it++)
    {
        if(!s1.count(*it))
        {
            v[t].mp[*it]++;
            Maxt = max(Maxt,v[t].mp[*it]);
        }
    }
}

bool cmp(const pair<char,int> & p1,const pair<char,int>p2)
{
    if(p1.first!=p2.first)
    {
        return p1.first < p2.first;
    } else{
        return p1.second < p2.second;
    }
}



int main() {
    char c;
    cin>>N>>M;
    for(int i = 0;i<M;i++)
    {
        Node node;
        cin>>node.full>>t>>K;
        for(int j = 0;j<K;j++)
        {
            cin>>c;
            node.ss.insert(c);
        }
        v.push_back(node);
    }

    //N
    for(int i = 0;i<N;i++)
    {
        double ans = 0;
        getchar();
        for(int j = 0;j<M;j++)
        {
            if(j) scanf(" ");
            scanf("(%d",&K);

            set<char>tmp;
            for(int k = 0;k<K;k++)
            {
                scanf(" %c",&c);
                tmp.insert(c);
            }

            scanf(")");
            if(tmp == v[j].ss) ans += v[j].full;
            else
            {
                addWrong(tmp,v[j].ss,j);
                if(isContain(tmp,v[j].ss)) ans += v[j].full*0.5;
            }
        }
        printf("%.1f\n",ans);
    }

    vector<pair<int,char>>wrong;
    for(int i = 0;i<M;i++)
    {
        for(auto it = v[i].mp.begin();it!=v[i].mp.end();it++)
        {
            if(it->second == Maxt)
            {
                wrong.push_back(make_pair(i+1,it->first));
//                cout<<i+1<<" "<<it->first<<endl;
            }
        }
    }
    if(wrong.size() == 0)
    {
        cout<<"Too simple"<<endl;
    } else{
        sort(wrong.begin(),wrong.end(),cmp);
        for(int i = 0;i<wrong.size();i++)
        {
            cout<<Maxt<<" "<<wrong[i].first<<"-"<<wrong[i].second<<endl;
        }
    }


    return 0;
}
/**
3 4
3 4 2 a c
2 5 1 b
5 3 2 b c
1 5 4 a b d e
(2 a c) (3 b d e) (2 a c) (3 a b e)
(2 a c) (1 b) (2 a b) (4 a b d e)
(2 b d) (1 e) (1 c) (4 a b c d)
**/

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值