Guest User

Untitled

a guest
Nov 16th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. #include<string>
  4. #include<map>
  5. #include<vector>
  6. #include<sstream>
  7. #include<cstdio>
  8. #define eps 1e-8
  9. using namespace std;
  10.  
  11. map<string,int>m;
  12.  
  13. int main(){
  14. int N;
  15. string s,a;
  16. string P[300];
  17. int k=0;
  18. vector<string>res[100];
  19. vector<string>resf;
  20. while(1){
  21. k++;
  22. m.clear();
  23. for(int i=0;i<100;i++)res[i].clear();
  24. resf.clear();
  25. scanf("%d",&N);
  26. if(N==0)break;
  27. getline(cin,s);
  28. for(int i=0;i<N;i++){
  29. getline(cin,s);
  30. // cout<<s<<endl;
  31. istringstream in(s);
  32. in>>P[i];
  33. while(in>>a){
  34. m[a]++;
  35. res[i].push_back(a);
  36. }
  37. }
  38. // cout<<m["direkt"]<<endl;
  39. double punt[200],pmax=0.0;
  40. for(int i=0;i<N;i++){
  41. punt[i]=0.0;
  42. for(int j=0;j<res[i].size();j++){
  43. punt[i]+=1.0*res[i][j].length()/m[res[i][j]];
  44. }
  45. if(punt[i]>pmax)pmax=punt[i];
  46. }
  47. printf("Round %d \n",k);
  48. for(int i=0;i<N;i++){
  49. if(abs(punt[i]-pmax)<eps)resf.push_back(P[i]);
  50. }
  51. int bm=resf.size();
  52. for(int i=0;i<bm;i++){
  53. if(i!=bm-1)cout<<resf[i]<<" ";
  54. else cout<<resf[i];
  55. }
  56. cout<<endl;
  57.  
  58. }
  59.  
  60. }
Add Comment
Please, Sign In to add comment