先上题目:

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. bzoj1179 [Apio2009]Atm——缩环最长路

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1179 tarjan 缩环,然后求到有酒吧的点的最长路即可: 但一开始想缩环后用拓扑序求答案, ...

  2. c++ string 解析ip

    比如输入是192.168.80.12-15,解析成192.168.80.12.192.168.80.13.192.168.80.14.192.168.80.15. #include <iostr ...

  3. Fisher 线性判别

    Multiplying both sides of this result by wT and adding w0, and making use of y(x)=wTx+w0 and  y(xΓ)= ...

  4. Hamming Distance(随机算法)

    http://acm.hdu.edu.cn/showproblem.php?pid=4712 题意:计算任意两个十六进制的数异或后1的最少个数. 思路:用随机数随机产生两个数作为下标,记录这两个数异或 ...

  5. json用法

    什么是JSON? JavaScript 对象表示法(JavaScript Object Notation). JSON是一种轻量级的数据交换格式,某个JSON格式的文件内部譬如可以长成这样: 1 2 ...

  6. HTML多媒体标记之字幕标记

    在HTML中,可以向页面中插入字幕,水平或垂直滚动显示文字信息,字幕标记的格式如下: <marquee 属性="值"...>滚动的文字信息</marquee> ...

  7. 关于Vue.js去掉#号路由

    正常启动后访问路由: 中间会自动加入一个#号 去掉#号: 在route文件夹下的index.js中加入mode: 'history', ①: ②: 关于mode说明: 默认值: ‘hash‘(浏览器) ...

  8. HTML <!DOCTYPE>标签

    一般一个基本html页面的结构,如下代码所示: <html> <head> <title>我是基本的页面结构</title> </head> ...

  9. HBase的集群搭建(1、3、5节点都适用)

    见 5 hbase-shell + hbase的java api

  10. 深入浅出java多态

    所谓多态就是指程序中定义的引用变量所指向的具体类型和通过该引用变量发出的方法调用在编程时并不确定,而是在程序运行期间才确定,即一个引用变量倒底会指向哪个类的实例对象,该引用变量发出的方法调用到底是哪个 ...