先上题目:

Happy Girls

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1356    Accepted Submission(s): 233

Problem Description
These days, Hunan TV host the big concert – Happy Girls.
Long1 and xinxin like it very much, they even use their cellphones to suppose the girl who they like most. This way is easy if you have enough money then you can make a contribution toward your lover.
But sometimes, it also causes the problem of injustice. Those who has a lot of money can support their lover in every second. So now, we make a rule to restrict them – every tel-number can just support once in one minute (i.e two messages should have difference bigger or equal 60s). 
As an exerllent programer, your mission is to count every Happy girl’s result.

 
Input
There are many cases. 
For every case:

The first line gives N, represents there are N happy gilrs numbered form 1 to N(N<=10) 
Then many lines follows(no more than 50000), each line gives the time one sent his/her message, the cellphone number and the number he/she support. They are sepatated by space.
The last line an message “#end”.

 
Output
In every case, you print “The result is : ”, then N line follows.
Each line begin with the Happy girls’ number, then a colon, then a bunch of “*” follows, the number of the “*” are Happy girls’ votes.
 
Sample Input
4
0:12:25 13854241556 1
0:15:52 15825422365 2
0:15:56 15825422365 3
0:18:55 13625415457 2
11:12:2 13954215455 4
5:41:55 13625415457 2
#end
 
Sample Output
The result is :
01 : *
02 : ***
03 :
04 : *
 
  题意:给出一系列手机号码,其发送信息的时间以及投票的对象,求最终每个被投票对象的得票数。这里有一个要求,就是对于同一个人的信息需要判断是不是在60秒以内连续发的,如果是,那当前这一次投票不计。这里可能有一点歧义,①60秒以内连续发多条短信,那是只以第一条短信为60秒的开始计时点还是每收到一条短信,都会以新的一条短信为计时的开始点。不过这里两种情况都会AC。
  做法就是先对每一个手机用户的投票情况进行排序,然后统计一遍就可以了。值得注意的是对于同一个用户连续两条短信的间距只要大于等于60秒就可以了。
  还有就是,这一题用C++交可能会WA,用G++交的话才会AC。
 
上代码:
 
 #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MAX 50004
#define LL long long
using namespace std; typedef struct{
LL ti;
LL num;
int p;
}vote; vote v[MAX];
int tot;
int girl[]; typedef struct{
LL la;
LL num;
}user; user u[MAX];
int o; void check(int t){
if(u[o].num==v[t].num){
if(u[o].la>= && v[t].ti-u[o].la<){
u[o].la=v[t].ti;
return;
}
}else{
o++;
u[o].num=v[t].num;
}
u[o].la=v[t].ti;
girl[v[t].p]++;
} bool cmp(vote x,vote y){
if(x.num<y.num) return ;
else if(x.num==y.num && x.ti<y.ti) return ;
return ;
} int main()
{
int t,k,t_[];
char a[];
//freopen("data.txt","r",stdin);
while(scanf("%d",&t)!=EOF){
getchar();
tot=;
memset(girl,,sizeof(girl));
memset(u,-,sizeof(u));
o=;
while(scanf("%s",a),a[]!='#'){
sscanf(a,"%d:%d:%d",&t_[],&t_[],&t_[]);
k=;
for(int i=;i<;i++){
k=k*+t_[i];
}
v[tot].ti=k;
scanf("%I64d",&v[tot].num);
scanf("%d",&v[tot].p);
tot++;
}
sort(v,v+tot,cmp);
for(int i=;i<tot;i++){
check(i);
}
printf("The result is :\n");
for(int i=;i<=t;i++){
printf("%02d : ",i);
for(int j=;j<girl[i];j++) putchar('*');
printf("\n");
}
}
return ;
}

3040

HDU - 3040 - Happy Girls的更多相关文章

  1. 【HDU 6017】 Girls Love 233 (DP)

    Girls Love 233 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)To ...

  2. HDU——T 1068 Girls and Boys

    http://acm.hdu.edu.cn/showproblem.php?pid=1068 Time Limit: 20000/10000 MS (Java/Others)    Memory Li ...

  3. 【hdu 1068】Girls and Boys

    [Link]:http://acm.hdu.edu.cn/showproblem.php?pid=1068 [Description] 有n个人,一些人认识另外一些人,选取一个集合,使得集合里的每个人 ...

  4. HDU 3294 (Manacher) Girls' research

    变形的求最大回文子串,要求输出两个端点. 我觉得把'b'定义为真正的'a'是件很无聊的事,因为这并不会影响到最大回文子串的长度和位置,只是在输出的时候设置了一些不必要的障碍. 另外要注意一下原字符串s ...

  5. 【转载】图论 500题——主要为hdu/poj/zoj

    转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并 ...

  6. hdu图论题目分类

    =============================以下是最小生成树+并查集====================================== [HDU] 1213 How Many ...

  7. HDU图论题单

    =============================以下是最小生成树+并查集====================================== [HDU] 1213 How Many ...

  8. HDU2063 过山车(二分匹配)

    过山车 HDU - 2063 RPG girls今天和大家一起去游乐场玩,终于可以坐上梦寐以求的过山车了.可是,过山车的每一排只有两个座位,而且还有条不成文的规矩,就是每个女生必须找个个男生做part ...

  9. hdu 2579 Dating with girls(2)

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2579 Dating with girls(2) Description If you have sol ...

随机推荐

  1. bzoj1898: [Zjoi2005]Swamp 沼泽鳄鱼

    一眼矩乘 把图分成12个,然后直接搞. #include<cstdio> #include<iostream> #include<cstring> #include ...

  2. Android网络连接监听

    接收系统网络服务的广播接收者 public class NetStateReceiver extends BroadcastReceiver { private Handler handler; pu ...

  3. js定义类和方法

    js中定义一个类 //定义一个user类 var user = function(){ //类中的属性 var age; //设置age的值 var setAge = function(age){ t ...

  4. [BZOJ1821][JSOI2010]部落划分

    感觉学了这么久还是有那么一丢丢进步的...上个学期看到这道题,虽然早就学过并查集和二分了但还是一点思路都没有,现在可以秒切了呢 思路就是二分+并查集,有些人说是生成树,其实它没有变成树,只是运用了生成 ...

  5. Cracking the Coding Interview 4.8

    You are given a binary tree in which each node contains a value. Design an algorithm to print all pa ...

  6. webApi上传服务,可重命名,可创建文件夹

    webApi上传服务,根据FileName重命名,根据Path创建文件夹 /// <summary> /// 上传文件 /// </summary> /// <retur ...

  7. P1401 城市(30分,正解网络流)

    题目描述 N(2<=n<=200)个城市,M(1<=m<=40000)条无向边,你要找T(1<=T<=200)条从城市1到城市N的路,使得最长的边的长度最小,边不能 ...

  8. Flex使用总结

    最近做的项目因为对浏览器的兼容要求是IE10以上,所以大胆的使用了Flex布局,这里总结一些使用心得仅供参考. 一,Flex简单介绍 Flex是Flexible Box的缩写,意为”弹性布局”.任何一 ...

  9. 关于Core里的 StartUp里的方法的理解。

    public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; ...

  10. SAP computer之program counter

    Program counter The program is stored in memory with the first instruction at binary address 0000, t ...