-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1058.cpp
More file actions
78 lines (71 loc) · 1.27 KB
/
1058.cpp
File metadata and controls
78 lines (71 loc) · 1.27 KB
1
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
77
78
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
struct inf{
int idx;
int score;
int n_c;
int wrong;
string s;
};
bool cmp(inf a,inf b){
return a.wrong !=b.wrong? a.wrong>b.wrong:a.idx<b.idx;
}
int main(){
int n,m;
cin>>n>>m;
inf *a = new inf [m];
for(int i=0;i<m;i++){
cin>>a[i].score>>a[i].n_c;
getline(cin,a[i].s);
a[i].s.erase(0,a[i].s.find_first_not_of(" "));//擦除首位的空格
a[i].idx=i+1;
a[i].wrong =0;
}
string jie;
for(int i=0;i<n;i++){
//cin>>jie;
getline(cin,jie);
int len = jie.length();
int j = 0,k=0,level=0,sum=0;
while(j<len){
string t;
if(jie[j]=='('){
k = j+1;
while(k++<len){
if(jie[k]==')'){
t = jie.substr(j+1,k-j-1);
if(t==a[level].s){
sum = sum+a[level].score;
level++;
break;}
else{
a[level].wrong++;
level++;
break;}
}
}
}
j++;
}
cout<<sum<<endl;
}
sort(a,a+m,cmp);
if(a[0].wrong==0)
cout<<"Too simple"<<endl;
else{
cout<<a[0].wrong;
//cout<<a[0].idx;
for(int i = 0;i<m;i++)
{
if(a[i].wrong==a[0].wrong)
cout<<" "<<a[i].idx;
if(a[i].wrong!=a[0].wrong)
break;
}
cout<<endl;
}
system("pause");
return 0;
}