10.20T1 大模拟

 

 

 

模拟,注意没有涂的情况

code:

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<map>
 4 #include<vector>
 5 #include<cstring>
 6 #include<algorithm>
 7 #define N 100005
 8 using namespace std;
 9 struct node {
10     string name;
11     int score;
12 } e[N];
13 bool cmp(const node&a,const node &b) {
14     if(a.score==b.score)return a.name<b.name;
15     return a.score>b.score;
16 }
17 struct T {
18     int comp,part;
19     bool ans[5];
20 } t[N];
21 int main() {
22     freopen("sheet.in","r",stdin);
23     freopen("sheet.out","w",stdout);
24     int n,m;
25     cin>>n>>m;
26     for(int i=1; i<=n; i++) {
27         cin>>e[i].name;
28     }
29     for(int i=1; i<=m; i++) {
30         cin>>t[i].comp>>t[i].part;
31         string answer;
32         cin>>answer;
33         for(int j=0; j<answer.size(); j++) {
34             t[i].ans[answer[j]-'A'+1]=1;
35         }
36     }
37     for(int o=1; o<=n; o++) {
38         string temp[5];
39         for(int i=1; i<=4; i++) {
40             cin>>temp[i];
41             temp[i]=' '+temp[i];
42         }
43         int tempans[5];
44         int score=0;
45         for(int i=1; i<=m; i++) {
46             memset(tempans,0,sizeof tempans);
47             for(int j=1; j<=4; j++) {
48                 if(temp[j][i]=='X') {
49                     tempans[j]=1;
50                 }
51             }
52             int flag=0;
53             for(int j=1; j<=4; j++) {
54                 if(t[i].ans[j]==tempans[j])continue;
55                 if(t[i].ans[j]==1&&tempans[j]==0) {
56                     flag=1;
57                     continue;
58                 } else {
59                     flag=2;
60                     break;
61                 }
62             }
63             int sum=0;
64             for(int i=1;i<=4;i++)sum+=tempans[i];
65             if(sum==0)flag=2;
66             if(flag==0)score+=t[i].comp;
67             if(flag==1)score+=t[i].part;
68             else continue;
69         }
70         e[o].score=score;
71     }
72     sort(e+1,e+n+1,cmp);
73     for(int i=1; i<=n; i++) {
74         cout<<e[i].name<<" "<<e[i].score<<'\n';
75     }
76     return 0;
77 }

over

posted @ 2018-10-20 14:52  saionjisekai  阅读(35)  评论(0编辑  收藏  举报