ccf csp认证202206-3

#include<bits/stdc++.h>
using namespace std;
struct users{
    string username;
    vector<string>opname;
    vector<string>sourcetype;
    vector<string>sourcename;
    vector<string>re_person;
    vector<string>re_group;
};
int main(){
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int n,m,q;
    cin >> n >> m >>q;
    users user[n];
    int nv,no,nn;
    for(int i=0;i<n;i++){
        cin >>user[i].username >> nv;
        for(int j=0;j<nv;j++){
            string opname;    
            cin >> opname;
            user[i].opname.push_back(opname);
        }
        cin >> no;
        for(int j=0;j<no;j++){
            string sourcetype;
            cin >> sourcetype;
            user[i].sourcetype.push_back(sourcetype); 
        }
        cin >> nn;
        for(int j=0;j<nn;j++){
            string sourcename;
            cin >> sourcename;
            user[i].sourcename.push_back(sourcename);
        }    
    }
    for(int i=0;i<m;i++){
        string username;
        cin >> username;
        int flag=0;
        for(int j=0;j<n;j++){
            if(username==user[j].username){
                flag = j;
                break;
            }
        }
        int ns;
        cin >> ns;
        char s;
        string re_name;
        for(int k=0;k<ns;k++){
            cin >> s >> re_name;
            if(s=='u'){
              user[flag].re_person.push_back(re_name);    
            }else{
              user[flag].re_group.push_back(re_name);    
            }
        }
    }
    vector<int>result;
    for(int i=0;i<q;i++){
        int flag = 0;
        string q_name;
        int ng;
        cin >> q_name >> ng;
        string q_opname,q_sourcetype,q_sourcename;
        string re[ng];
        for(int j=0;j<ng;j++){
            cin >> re[j];
        }
        cin >> q_opname >> q_sourcetype >> q_sourcename;
            for(int k=0;k<n;k++){
                if((count(user[k].re_person.begin(),user[k].re_person.end(),q_name))==1){
                    if(count(user[k].opname.begin(),user[k].opname.end(),q_opname)==1 || 
                       count(user[k].opname.begin(),user[k].opname.end(),"*")==1){
                         if(count(user[k].sourcetype.begin(),user[k].sourcetype.end(),q_sourcetype)==1 || 
                           count(user[k].sourcetype.begin(),user[k].sourcetype.end(),"*")==1){
                           if(count(user[k].sourcename.begin(),user[k].sourcename.end(),q_sourcename)==1
                           ||user[k].sourcename.size()==0){
                                  result.push_back(1);
                                  flag =1;
                                  break;
                           }
                        }
                     }
                }
            }
        if(flag !=1){
            for(int k=0;k<ng;k++){
             for(int j=0;j<n;j++){
                if((count(user[j].re_group.begin(),user[j].re_group.end(),re[k]))==1){
                    if(count(user[j].opname.begin(),user[j].opname.end(),q_opname)==1 || 
                       count(user[j].opname.begin(),user[j].opname.end(),"*")==1){
                         if(count(user[j].sourcetype.begin(),user[j].sourcetype.end(),q_sourcetype)==1 || 
                           count(user[j].sourcetype.begin(),user[j].sourcetype.end(),"*")==1){
                           if(count(user[j].sourcename.begin(),user[j].sourcename.end(),q_sourcename)==1
                           ||user[j].sourcename.size()==0){
                                  result.push_back(1);
                                  flag=2;
                                  break;
                           }
                        }
                     }
                }
            }
            if(flag == 2){
                break;
            }
            }
        }
        if(flag==0){
            result.push_back(0);
        }
    }
    for(int i=0;i<result.size();i++){
        cout << result[i] << endl;
    }
}

hai就这样吧,大模拟题不想做。 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值