티스토리 뷰

https://www.acmicpc.net/problem/9375

 

9375번: 패션왕 신해빈

문제 해빈이는 패션에 매우 민감해서 한번 입었던 옷들의 조합을 절대 다시 입지 않는다. 예를 들어 오늘 해빈이가 안경, 코트, 상의, 신발을 입었다면, 다음날은 바지를 추가로 입거나 안경대신

www.acmicpc.net


C++ 소스 코드

#include <iostream>
#include <string>
#include <map>
#include <set>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    map<string, int> mp;
    set<string> st;
    int tc,n,ans;
    cin >> tc;
    while(tc--){
        mp.clear();
        st.clear();
        ans = 1;
        cin >> n;
        string name,type;
        for(int i=0;i<n;i++){
            cin >> name >> type;
            mp[type]++;
            st.insert(type);
        }
        set<string>::iterator iter;
        for(iter = st.begin(); iter!=st.end(); ++iter){
            ans*= mp[*iter]+1;
        }
        cout << ans-1 << '\n';
    }
    return 0;
}
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/10   »
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
글 보관함