先上题目:

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. 树形 DP 总结

    树形 DP 总结 本文转自:http://blog.csdn.net/angon823/article/details/52334548 介绍 1.什么是树型动态规划 顾名思义,树型动态规划就是在“树 ...

  2. B1085 [SCOI2005]骑士精神 A*搜索

    其实就是一个爆搜加剪枝.直接爆搜肯定不行,而A*算法则是想假如剩下都是最优的话,我当前步数还是不足以达到这个状态,那么就直接返回,因为最优状态也无法做到显然不行. 这道题可以用A*最主要就是因为有15 ...

  3. APP-Android:APK

    ylbtech-APP-Android:APK APK是AndroidPackage的缩写,即Android安装包(apk).APK是类似Symbian Sis或Sisx的文件格式.通过将APK文件直 ...

  4. 利用tensorflow实现前向传播

    import tensorflow as tf w1 = tf.Variable(tf.random_normal((2, 3), stddev=1, seed=1))w2 = tf.Variable ...

  5. 一段时间加载的js函数

    <html><head><meta charset="utf8"><script type="text/javascript&q ...

  6. wap 5.23 网测几道题目

    1. n个犯人,m个省份, 如果相邻的2个犯人来自同一省份,则是不安全的,求不安全的个数. 正难则反,用全部的个数减去非法的个数,就是最后的答案. m^n - m * (m - 1) ^ (n - 1 ...

  7. Bootstrap中container与container-fluid的区别

    /*0-768px以上宽度container为100%*/ .container { padding-right: 15px; padding-left: 15px; margin-right: au ...

  8. MainActivity 多个Fragment 内存被回收

    0. 前言 应用首页采用Activity +Tab 模式,多个Fragment 替换显示隐藏 FragmentTransaction transaction = getSupportFragmentM ...

  9. JavaScript中比较运算符的使用

    比较运算符的基本操作过程是:首先对操作数进行比较,这个操作数可以是数字也可以是字符串,然后返回一个布尔值true或false. 在JavaScript中常用的比较运算符如下表所示. 例如,某商场店庆搞 ...

  10. 【Oracle】服务器端监听配置

    一.静态监听 创建端口为1521的监听,静态注册,本机ip:192.168.10.2 [oracle@localhost ~]$ vi /u01/app/oracle/product/11.2.0/d ...