2013年8月11日

UVa 11348 - Exhibition

#include <cstdio>

int main() {
  int K, C = 1;
  scanf("%d", &K);
  while (K--) {
    int N, num[10001] = {}, owner[10001] = {}, maxType = 0;
    bool unique[10001] = {};
    scanf("%d", &N);
    for (int i = 1; i <= N; i++) {
      int M;
      scanf("%d", &M);
      while (M--) {
        int type;
        scanf("%d", &type);
        num[type]++;
        if (!owner[type]) {
          unique[type] = true;
        } else if (owner[type] != i) {
          unique[type] = false;
        }
        owner[type] = i;
        maxType = type > maxType ? type : maxType;
      }
    }
    int all = 0, own[99] = {};
    for (int i = 0; i <= maxType; i++) {
      all += unique[i];
      own[owner[i]] += unique[i];
    }
    printf("Case %d: ", C++);
    for (int i = 1; i <= N; i++) {
      printf("%.6lf%%%s", own[i] / (double)all * 100.0, i == N ? "\n" : " ");
    }
  }
  return 0;
}

沒有留言:

張貼留言