Sicily 14184. Incognito
来源:互联网 发布:mac上photoshop 编辑:程序博客网 时间:2024/05/17 07:57
14184. Incognito
Constraints
Time Limit: 1 secs, Memory Limit: 256 MB
Description
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.
Input
On the first line one positive number: the number of test cases, at most 100. After that per test case:
- one line with an integer n (0 ≤ n ≤ 30): the number of available attributes.
- n lines with two space-separated strings: the name and the category of the attribute. All strings consist of at least 1 and at most 20 lowercase letters. Within a test case all names are distinct.
Output
Per test case:
- one line with an integer: the number of possible distinct disguises that can be made with the given attributes, such that at most one attribute from each category is used.
Sample Input
23hat headgearsunglasses eyewearturban headgear3mask facesunglasses facemakeup face
Sample Output
53
Problem Source
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;}
0 0
- Sicily 14184. Incognito
- incognito的查询接口
- Google浏览器 隐身模式 -incognito
- Sicily 1027
- sicily 1007
- sicily 1795
- sicily 1036
- sicily 1419
- sicily 1889
- sicily 1684
- sicily 1686
- sicily 1004
- sicily 1135
- sicily 1152
- sicily 1151
- sicily 1002
- sicily 1156
- sicily 1424
- asihttprequest cookie
- 第七题第四小题
- DataTable中Rows.RemoveAt(i)和Rows(i).Delete的区别
- NSPredict
- cocos2dx 3.0 了解有限状态机02
- Sicily 14184. Incognito
- source insight中的快捷键总结
- 第七题第五小题
- 四则运算
- 他真的不是我兄弟:像素跟点大不同
- oj 题目分类(转载的先存着)
- ios::sync_with_stdio(false);
- 定义图文并茂的html5新标签-figure、figcaption
- 第三章第8题