티스토리 뷰

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
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
 
int main() {
    int t;
    cin >> t;
    string cloth, kind;
 
    while (t--) {
        int n;
        cin >> n;
        map<stringint> m; // 옷 종류와 종류별 수를 담는 map
        while (n--) {
            cin >> cloth >> kind;
            m[kind]++// 옷 종류별 수 갱신
        }
        
        long long res = 1;
        for(auto it = m.begin(); it != m.end(); it++){
            res *= it->second + 1// 각 종류별 경우의 수 = (하나씩 입는 경우) + (안입는 경우)
        }
        
        res--// 아무것도 안입은 경우 제외
        cout << res << endl;
    }
}
cs

 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/07   »
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
글 보관함