Advertisement
juanjo12x

UVA_11348_Exhibition

Aug 14th, 2014
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. #include <cstring>
  5. #include <string>
  6. #include <cctype>
  7. #include <stack>
  8. #include <queue>
  9. #include <list>
  10. #include <vector>
  11. #include <map>
  12. #include <set>
  13. #include <sstream>
  14. #include <stdlib.h>
  15. #include <cmath>
  16. #define FOR(i,A) for(typeof (A).begin() i = (A).begin() ; i != (A).end() ; i++)
  17. #define mp make_pair
  18. #define debug( x ) cout << #x << " = " << x << endl
  19. #define clr(v,x) memset( v, x , sizeof v )
  20. #define all(x) (x).begin() , (x).end()
  21. #define rall(x) (x).rbegin() , (x).rend()
  22. #define TAM 110
  23.  
  24. using namespace std;
  25.  
  26. typedef pair<int,int> ii ;
  27. typedef long long ll ;
  28. typedef long double ld ;
  29. typedef pair<int,ii> pii ;
  30.  
  31.  
  32.  
  33. int main() {
  34.     int t,n,a,aux;
  35.     scanf("%d",&t);
  36.     int cont=1;
  37.     while(t--){
  38.         map<int,int> mp;set<int> s;double osp;bool entro=true;
  39.         map <int,int> ::iterator it;
  40.         scanf("%d",&n);
  41.         if(n==0) {
  42.          printf("Case %d: \n",cont);cont++;continue;
  43.         }
  44.         for(int i=0;i<n;i++){
  45.             scanf("%d",&a);
  46.            
  47.             for(int j=0;j<a;j++){
  48.                 scanf("%d",&aux);
  49.                 if(mp.count(aux)==0){
  50.                     mp[aux]=i+1;s.insert(aux);
  51.                 }else if(mp.count(aux)!=0 && mp[aux]!=i+1){
  52.                     mp[aux]=0;s.erase(aux);
  53.                 }
  54.             }
  55.         }
  56.         if(mp.empty()){printf("Case %d: \n",cont);cont++;continue;}
  57.         printf("Case %d: ",cont);int cont1;
  58.         for(int i=0;i<n;i++){
  59.             cont1=0;
  60.             for(it=mp.begin();it!=mp.end();it++){
  61.                 //printf("%d",it->second);
  62.              if((it->second)==i+1) cont1++;
  63.             }
  64.             if(s.size()!=0) osp=((double)cont1/(double)(s.size()))*(100.0);
  65.             else osp=0;
  66.            
  67.             if(i!=n-1){
  68.                   printf("%.6lf%% ",osp);
  69.             }else printf("%.6lf%%\n",osp);
  70.         }
  71.         cont++;
  72.     }
  73.     return 0;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement