这个题没有完全AC,实在不知道第三个测试点为什么会错误,最后一个测试点超时,回头再改改吧,心累,(;′⌒`)
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class p1058 {
public static void main(String[] args) throws Exception{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String [] inputStr=br.readLine().split("[ ]");
int stuNum=Integer.parseInt(inputStr[0]);
int proNum=Integer.parseInt(inputStr[1]);
int [] wrongs=new int[proNum];
int [] score=new int[stuNum];
String []result=new String[proNum];
//输入多选题的正确内容,并存储在result数组中
for (int i = 0; i<proNum; i++) {
String[] proInfo=br.readLine().split("[ ]");
result[i]=proInfo[0];
int j=3;
while(j<proInfo.length){
result[i]+=proInfo[j++];
}
}
//输入学生的答案,并且处理字符串
//k用于遍历结果数组
for (int i = 0; i <stuNum; i++) {
int k=0;
String stuInfo=br.readLine();
String stuAns="";
char[] chs=stuInfo.toCharArray();
int j=0;
boolean isRight=false;
while (j<chs.length){
if(chs[j]=='('){
isRight=true;
}
if(isRight){
if(chs[j]>='a'&&chs[j]<='z'){
stuAns+=chs[j];
}
}
if(chs[j]==')'){
if(result[k].substring(1).equals(stuAns)){
score[i]+=Integer.parseInt(result[k].charAt(0)+"");
k++;
}else{
wrongs[k]+=1;
k++;
}
isRight=false;
stuAns="";
}
j++;
}
}
//开始处理结果数组
for (int i : score) {
System.out.println(i);
}
//处理错误数组
//先获得数组中的最大值
int maxId=0;
boolean flag=false;
for (int i = 0; i < wrongs.length; i++) {
if(wrongs[i]>wrongs[maxId]){
maxId=i;
flag=true;
}
}
if(flag) {
String outPro = wrongs[maxId] + " ";
for (int i = 0; i < wrongs.length; i++) {
if (wrongs[i] == wrongs[maxId]) {
outPro += (i+1) + " ";
}
}
outPro = outPro.trim();
System.out.println(outPro);
}else{
System.out.println("Too simple");
}
}
}