Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- #include<string>
- #include<map>
- #include<vector>
- #include<sstream>
- #include<cstdio>
- #define eps 1e-8
- using namespace std;
- map<string,int>m;
- int main(){
- int N;
- string s,a;
- string P[300];
- int k=0;
- vector<string>res[100];
- vector<string>resf;
- while(1){
- k++;
- m.clear();
- for(int i=0;i<100;i++)res[i].clear();
- resf.clear();
- scanf("%d",&N);
- if(N==0)break;
- getline(cin,s);
- for(int i=0;i<N;i++){
- getline(cin,s);
- // cout<<s<<endl;
- istringstream in(s);
- in>>P[i];
- while(in>>a){
- m[a]++;
- res[i].push_back(a);
- }
- }
- // cout<<m["direkt"]<<endl;
- double punt[200],pmax=0.0;
- for(int i=0;i<N;i++){
- punt[i]=0.0;
- for(int j=0;j<res[i].size();j++){
- punt[i]+=1.0*res[i][j].length()/m[res[i][j]];
- }
- if(punt[i]>pmax)pmax=punt[i];
- }
- printf("Round %d \n",k);
- for(int i=0;i<N;i++){
- if(abs(punt[i]-pmax)<eps)resf.push_back(P[i]);
- }
- int bm=resf.size();
- for(int i=0;i<bm;i++){
- if(i!=bm-1)cout<<resf[i]<<" ";
- else cout<<resf[i];
- }
- cout<<endl;
- }
- }
Add Comment
Please, Sign In to add comment