标签:sicily
Time Limit: 1 secs, Memory Limit: 256 MB
Spies use attributes to disguise themselves to make sure that they are not recognized. For example, when putting on sunglasses, a spy suddenly looks completely different and cannot be recognized anymore. Every combination of attributes gives a different appearance, but not all combinations are possible. For example, a hat and a turban are both headgear and cannot be used at the same time. Given the list of available attributes, compute how many distinct disguises can be made.
On the first line one positive number: the number of test cases, at most 100. After that per test case:
Per test case:
2 3 hat headgear sunglasses eyewear turban headgear 3 mask face sunglasses face makeup face
5 3
2015年每周一赛第七场
#include <iostream> #include <map> #include <string> using namespace std; int n; int ans; map<string, int> m; int main() { int caseNum; cin >> caseNum; while (caseNum--) { cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s >> s; if (m.find(s) == m.end()) m[s] = 1; else m[s]++; } ans = 1; for (map<string, int>::iterator iter = m.begin(); iter != m.end(); iter++) { ans *= iter->second + 1; } cout << ans - 1 << endl; m.clear(); } return 0; }
标签:sicily
原文地址:http://blog.csdn.net/u012925008/article/details/45136125