我不认为我这题那里写错了,第5个测试点应该是大数据测试,我自己试试了,在试了试,发现AC过的代码,有点数据对的,有些数据不对的,不知道怎么回事。
代码:
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;
typedef struct{
double sco;
int opn,trn,fan;
char ans[5];
int f[5];
}quiz;
int judge(char a[5],quiz *b){
int tag=2;
int norm[5]={0};
for(int i=0;i<5;i++)
norm[b->ans[i]-'a']++;
for(int i=0;i<5;i++){
norm[a[i]-'a']--;
}
for(int i=0;i<5;i++)
if(norm[i]>0){
if(tag==2)
tag=1;
b->f[i]+=1;
}
else if(norm[i]<0){
tag=0;
b->f[i]+=1;
}
return tag;
}
int main(){
int n,m,k,num;
double get;
char s[101];
cin>>n>>m;
quiz q[101]={0};
for(int i=0;i<m;i++){
cin>>q[i].sco>>q[i].opn>>q[i].trn;
k=0;
for(int j=0;j<q[i].trn;j++){
cin>>q[i].ans[k++];
}
}
cin.get();
for(int i=0;i<n;i++){
char a[5]={0};
num=k=0;
get=0;
cin.getline(s,101);
for(int j=0;j<strlen(s);j++){
if(s[j]==')'){
int v=judge(a,&q[num]);
if(v==0)
q[num].fan++;
else if(v==1)
get+=0.5*q[num].sco;
else
get+=q[num].sco;
// cout<<a<<" "<<v<<" "<<get<<endl;
num++;
memset(a,0,sizeof(a));
k=0;
}
else if(s[j]>='a'&&s[j]<='e'){
a[k++]=s[j];
}
}
printf("%.1f\n",get);
}
int mm=0;
for(int i=0;i<m;i++){
for(int j=0;j<5;j++){
// cout<<q[i].f[j]<<" ";
if(q[i].f[j]>mm)
mm=q[i].f[j];
}
// cout<<endl;
}
if(mm==0)
printf("Too simple\n");
else{
for(int i=0;i<m;i++){
for(int j=0;j<5;j++){
if(q[i].f[j]==mm)
printf("%d %d-%c\n",mm,i+1,j+'a');
}
}
}
return 0;
}
测试数据如下:
20 4
3 4 2 a c
2 5 1 b
5 3 2 b c
1 5 4 a b d e
(2 a c) (1 b) (2 a b) (4 a b d e)
(2 b d) (1 e) (1 c) (4 a b c d)
(2 a c) (3 b d e) (2 a c) (3 a b e)
(2 a c) (1 b) (2 a b) (4 a b d e)
(2 b d) (1 e) (1 c) (4 a b c d)
(2 a c) (3 b d e) (2 a c) (3 a b e)
(2 a c) (1 b) (2 a b) (4 a b d e)
(2 b d) (1 e) (1 c) (4 a b c d)
(2 a c) (3 b d e) (2 a c) (3 a b e)
(2 a c) (1 b) (2 a b) (4 a b d e)
(2 b d) (1 e) (1 c) (4 a b c d)
(2 a c) (3 b d e) (2 a c) (3 a b e)
(2 a c) (1 b) (2 a b) (4 a b d e)
(2 b d) (1 e) (1 c) (3 b c d)
(2 a c) (3 b d e) (1 d) (3 a b e)
(1 b c) (1 b) (2 a b) (4 a b d e)
(2 b d) (1 e) (1 c) (4 a b c d)
(2 a c) (2 b d) (2 a c) (3 a b e)
(2 a c) (1 b) (2 a b) (4 a b d e)
(3 b c d) (1 e) (1 c) (4 a b c d)