// 我写完H的时候说他读懂了这题,说了题意给我,(其实我没听懂,应该是刚过H,太激动,没心情听==、、、)
//
然后他说暴力可以,我就叫他写,然后我就去看室友打lu ,
// 后来他卡死了==。我重新写也是 wa==
// 后来他发现用
string 数组过不了==。,我理解错题意--
// 后面我们一起改,相差十几秒一起A==
//
思路是把每位作者的作品都记录下来,然后看对这些作品被引用次数经行排序
// 然后。。。。。。看代码 hehe
数组那里
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iostream>
#include<queue>
#include<stack>
#include<map>
#include<cmath>
#include<bitset>
#define
BUG printf("hehe\n")
#define INF 0x3f3f3f3f
#define ll __int64
#define
lowbit(x) x&-x
using namespace std;
struct node
{
string name ;
int ans ,next[110] ,cnt ;
}qe[110] ;
int num[110] ,map1[110] ,hehe[110] ;
char a[110]
;
map<string,int>ss ;
bool cmp( node a , node b )
{
return (a.ans >
b.ans) || (a.ans == b.ans && a.name < b.name) ;
}
bool cmp1(
int a ,int b )
{
return a > b ;
}
int
main()
{
int n , m ,i ,k ;
int j
, T ,tt ,rr ;
string str ;
//
freopen("in.txt","r",stdin) ;
while(scanf("%d",&n) !=
EOF )
{
if(n==0) break ;
memset(num,0,sizeof(num)) ;
ss.clear() ;
tt = 0
;
for( i = 1 ; i <= n ;i++
)
{
cin
>> str
;
if(ss[str])
{
m = ss[str]
;
qe[m].cnt++
;
k = qe[m].cnt
;
qe[m].next[k] = i
;
}
else
{
tt++
;
ss[str] = tt
;
qe[tt].ans = 0
;
qe[tt].name = str
;
qe[tt].cnt = 1
;
qe[tt].next[1] = i
;
}
}
for( i = 1 ; i <= n ;i++
)
{
cin
>> a
;
m =
strlen(a)
;
for( j =
0 ; j < m;j++ )if(a[j] == ‘1‘ && j+1 !=
i)
num[j+1]++ ;
}
for( i = 1 ; i <= tt ;i++
)
{
m =
qe[i].cnt
;
int ans
= 0 ;
rr =
1 ;
for( j
= 1 ; j <= m ;j++ )
{
int uu = qe[i].next[j]
;
hehe[rr++] = num[uu]
;
}
sort(hehe+1,hehe+rr,cmp1)
;
hehe[rr]
= 0
;
//cout << hehe[1] <<
endl;
for(
j = 1 ; j < rr ;j++ ) if(hehe[j] < j ) break
;
qe[i].ans = j-1 ;
}
sort(qe+1,qe+1+tt,cmp)
;
for( i = 1 ; i<= tt ;i++
)
cout
<< qe[i].name << " " << qe[i].ans << endl
;
puts("") ;
}
return 0
;
}
2009年广东省大学生程序设计竞赛 E,布布扣,bubuko.com
原文:http://www.cnblogs.com/20120125llcai/p/3661942.html