SRM323 D2H ProductBundling

TopCoder Statistics - Problem Statement

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2010, TopCoder, Inc. All rights reserved.

ある商品に対しての買う客の集合を列挙する.別の商品に対しても同じ集合である場合,この商品をまとめても良い.行列を縦に見てsetに投げる.

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
32
33
34
35
36
37
38
39
40
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define INF 1<<30
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

class ProductBundling {

    public:

    int howManyBundles(vector <string> data) {
      int n = data.size();
      int m = data[0].size();

      set<string> st;
      rep(j, m) {
          string s = "";
          rep(i, n) {
              s += data[i][j];
          }
          st.insert(s);
      }

      return st.size();
    }
};
Nov 18th, 2016