题目
思路
这题考的其实不难,关键点是学生答案的输入用()来分隔每一道题。用cin就只能用string保存,再遍历判断,非常麻烦。 说实话,我非常不喜欢用scanf,直到这题教我做人……scanf对于要求格式的输入,真香!
代码参考自秦神
AC代码
#include<bits/stdc++.h>
using namespace std
;
struct test
{
int score
;
int ans
;
int right
;
string rans
;
};
int main(){
int n
,m
; cin
>>n
>>m
;
test a
[m
];
for(int i
=0;i
<m
;i
++){
scanf("%d %d %d",&a
[i
].score
,&a
[i
].ans
,&a
[i
].right
);
char temp
;
for(int j
=0;j
<a
[i
].right
;j
++){
cin
>>temp
;
a
[i
].rans
+=temp
;
}
}
int wrong
[m
] = {0};
for(int i
=0;i
<n
;i
++){
getchar();
int sco
= 0;
for(int j
=0;j
<m
;j
++){
if(j
!= 0) scanf(" ");
string str
;
int k
;
char s
;
scanf("(%d", &k
);
for(int q
= 0; q
< k
; q
++){
scanf(" %c", &s
);
str
+= s
;
}
scanf(")");
if(str
== a
[j
].rans
) sco
+= a
[j
].score
;
else wrong
[j
] ++;
}
cout
<<sco
<<endl
;
}
int max
= -1;
for(int i
= 0; i
< m
; i
++){
if(max
< wrong
[i
]) max
= wrong
[i
];
}
if(max
== 0) cout
<< "Too simple";
else{
cout
<< max
;
for(int i
= 0; i
< m
; i
++){
if(max
== wrong
[i
]) cout
<< " " << i
+1;
}
}
return 0;
}
转载请注明原文地址:https://ipadbbs.8miu.com/read-64734.html