比赛 20121106 评测结果 AAAAAAAAAEWE
题目名称 H 指数因子 最终得分 75
用户昵称 feng 运行时间 0.150 s
代码语言 C++ 内存使用 3.15 MiB
提交时间 2012-11-06 10:04:07
显示代码纯文本
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<map>
#include<string>
using namespace std;
int n,p;
string s;
struct node{
	string s;
	int x;
}a[200];
map<int,string> set;
map<string,int> setans;
int ans[200];
int sum[200];
bool f[200];
bool cmp(int a,int b){
	return a>b;
}
int minn(int a,int b){
	return a<b?a:b;
}
bool cmp1(node a,node b){
	if (a.x>b.x)
		return true;
	string s1=a.s;
	string s2=b.s;
	for (int i=1;i<minn(s1.size(),s2.size());i++){
		if (s1[i]>s2[i]) return false;
		if (s1[i]<s2[i]) return true;
	}
	return s1.size()<s2.size();
}
int main()
{
	freopen("publish.in","r",stdin);
	freopen("publish.out","w",stdout);
	memset(f,true,sizeof(f));
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>s;
		set[i]=s;
	}
	for (int i=1;i<=n;i++){
		cin>>s;
		int tmp=s.size();
		for (int j=0;j<tmp;j++)
			if (s[j]=='1')
				sum[j]++;
	}
	for (int i=0;i<n;i++)
		if (f[i]){
			p=1;
			ans[p]=sum[i];
			f[i]=false;
			for (int j=i+1;j<n;j++)
				if (set[j]==set[i]){
					ans[++p]=sum[j];
					f[j]=false;
				}
			sort(ans+1,ans+p+1,cmp);
			int j=p;
			for (;j>=1;j--)
				if (ans[j]>=j){
					
					break;
				}
			setans[set[i]]=j;
		}
	map<string,int>::iterator iter;
	iter=setans.begin();
	p=0;
	for (;iter!=setans.end();iter++){
		a[++p].s=iter->first;
		a[p].x=iter->second;
	}
	sort(a+1,a+p+1,cmp1);
	for (int i=1;i<=p;i++)
		cout<<a[i].s<<' '<<a[i].x<<endl;
	return 0;
}