50024. Grade
難度:2/51
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <ctype.h>
typedef struct problem{
int no_answer;
bool ans[5];
} problem;
int n, r, w;
int m;
problem correct[55];
problem student[55];
inline static int max(int a, int b){
if(a > b) return a;
else return b;
}
void get_problem_ipt(problem* p){
char s[16]; scanf("%s", s);
int n = strlen(s);
for(int i = 0; i < 5; i++) p->ans[i] = false;
if(!strcmp(s, "N/A")){
p->no_answer = true;
return;
}
else{
p->no_answer = false;
for(int i = 0; i < n; i++){
char ch = s[i];
if(islower(ch)){
p->ans[ch - 'a'] = true;
}
else{
p->ans[ch - 'A'] = true;
}
}
return;
}
}
int compare_ans(problem* cor, problem* stu){
if(stu->no_answer == true) return 0;
else{
for(int i = 0; i < 5; i++){
if(cor->ans[i] != stu->ans[i]) return -w;
}
return r;
}
}
int main(){
while(scanf("%d %d %d", &n, &r, &w) != EOF){
// get correct ans
for(int i = 0; i < n; i++) get_problem_ipt(&correct[i]);
// get student ans
int m; scanf("%d", &m);
for(int i = 0; i < m; i++){
for(int i = 0; i < n; i++) get_problem_ipt(&student[i]);
int ans = 0;
for(int i = 0; i < n; i++){
ans += compare_ans(&correct[i], &student[i]);
}
printf("%d\n", max(ans, 0));
}
}
return 0;
}