emmmmm,只有50分,,不知道哪儿没考虑到.......改了好多次... 后来发现参数不一定是数字....但是也只有70
//70
#include <iostream>
#include <cstdio>
#include <map>
#include <cstring>
#include <vector>
#include <cmath>
#include <sstream>
using namespace std;
int main() {
string s;
cin >> s;
int n;
map<char, int> a;
for(int i=0; s[i]; i++) {
if(s[i] == ':')
continue;
if(s[i+1] && s[i+1] ==':'){
if(a[s[i]] == -2){
a[s[i]] == -1;
} else a[s[i]] = -3;
}else a[s[i]] = -2;
}
cin >> n;
cin.get();
for(int i=0; i<n; i++) {
string temp;
map<char, string> b;
getline(cin, temp);
stringstream ss(temp);
string t;
char pre;
ss >> t;
while(ss >> t) {
if(a[pre] == -3 || a[pre] == -1){
b[pre] = t;
} else if (t[0] == '-') {
if(t.length() > 2)break;
if(a[t[1]] < 0)
b[t[1]] = "";
else break;
}else break;
pre = t[1];
// cout << t << endl;
}
cout << "Case " << i+1 << ": ";
/* for(map<char, int>::iterator it = a.begin(); it != a.end(); it++){
cout << "-" << it->first << " " << it->second << endl;
}
*/
for(map<char, string>::iterator it = b.begin(); it != b.end(); it++) {
if((it -> second).length() > 0) {
cout << "-" << it->first << " " << it->second << " ";
}else cout << "-" << it->first << " ";
}
cout << endl;
}
return 0;
}
//50
#include <iostream>
#include <cstdio>
#include <map>
#include <cstring>
#include <vector>
#include <cmath>
#include <sstream>
using namespace std;
int main() {
string s;
cin >> s;
int n;
map<char, int> a;
for(int i=0; s[i]; i++) {
if(s[i] == ':')
continue;
if(s[i+1] ==':'){
if(a[s[i]] == -2){
a[s[i]] == -1;
} else a[s[i]] = -3;
}else a[s[i]] = -2;
}
cin >> n;
cin.get();
for(int i=0; i<n; i++) {
string temp;
map<char, int> b;
getline(cin, temp);
stringstream ss(temp);
string t;
char pre;
ss >> t;
while(ss >> t) {
if (t[0] == '-') {
if(t.length() > 2)break;
if(a[t[1]] <0)
b[t[1]] = -1;
else break;
} else if (isdigit(t[0])) {
if(a[pre] != -3 && a[pre] != -1)break;
int j = 0, tmp = 0;
while (t[j] && isdigit(t[j])) {
tmp *= 10;
tmp += t[j] - '0';
j++;
}
if(j != t.length()) {
break;
}
b[pre] = tmp;
} else break;
pre = t[1];
// cout << t << endl;
}
cout << "Case " << i+1 << ": ";
/* for(map<char, int>::iterator it = a.begin(); it != a.end(); it++){
cout << "-" << it->first << " " << it->second << endl;
}
*/
for(map<char, int>::iterator it = b.begin(); it != b.end(); it++) {
if(it -> second > 0) {
cout << "-" << it->first << " " << it->second << " ";
}else cout << "-" << it->first << " ";
}
cout << endl;
}
return 0;
}
#include <iostream>
#include <cstdio>
#include <map>
#include <cstring>
#include <vector>
#include <cmath>
#include <sstream>
using namespace std;
int main() {
string s;
cin >> s;
int n;
map<char, int> a;
for(int i=0; s[i]; i++) {
if(s[i] == ':')
continue;
a[s[i]] = -2;
if(s[i+1] ==':') a[toupper(s[i])] = -3;
}
cin >> n;
cin.get();
for(int i=0; i<n; i++) {
string temp;
map<char, int> b;
getline(cin, temp);
stringstream ss(temp);
string t;
char pre;
while(ss >> t) {
if (t[2] == '\0') {
if (t[0] == '-') {
if(a[t[1]] < 0)
b[t[1]] = -1;
else if(a[t[1]] == 0)
break;
} else if (isdigit(t[0])) {
int j = 0, tmp = 0;
while (t[j]) {
tmp *= 10;
tmp += t[j] - '0';
j++;
}
if(a[toupper(pre)] == -3 || b[toupper(pre)] > 0 )
b[pre] = tmp;
else break;
}
pre = t[1];
} else break;
// cout << t << endl;
}
cout << "Case " << i+1 << ": ";
/* for(map<char, int>::iterator it = a.begin(); it != a.end(); it++){
cout << "-" << it->first << " " << it->second << endl;
}
*/
for(map<char, int>::iterator it = b.begin(); it != b.end(); it++) {
if(it->second == -1) {
cout << "-" << it->first << " ";
it->second = -2;
}
if(it -> second > 0) {
cout << "-" << it->first << " " << it->second << " ";
it ->second = -2;
}
}
cout << endl;
}
return 0;
}