I Love This Game
Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4663    Accepted Submission(s): 1598

Problem Description
Do you like playing basketball ? If you are , you may know the NBA Skills Challenge . It is the content of the basketball skills . It include several parts , such as passing , shooting , and so on. After completion of the content , the player who takes the shortest time will be the winner . Now give you their names and the time of finishing the competition , your task is to give out the rank of them ; please output their name and the rank, if they have the same time , the rank of them will be the same ,but you should output their names in lexicographic order.You may assume the names of the players are unique.

Is it a very simple problem for you? Please accept it in ten minutes.

Input
This problem contains multiple test cases! Ease test case contain a n(1<=n<=10) shows the number of players,then n lines will be given. Each line will contain the name of player and the time(mm:ss) of their finish.The end of the input will be indicated by an integer value of zero.

Output
The output format is shown as sample below.
Please output the rank of all players, the output format is shown as sample below;
Output a blank line between two cases.

Sample Input
10
Iverson 17:19
Bryant 07:03
Nash 09:33
Wade 07:03
Davies 11:13
Carter 14:28
Jordan 29:34
James 20:48
Parker 24:49
Kidd 26:46
0

Sample Output
Case #1
Bryant 1
Wade 1
Nash 3
Davies 4
Carter 5
Iverson 6
James 7
Parker 8
Kidd 9
Jordan 10

#include <stdio.h>
#include <string.h>
struct rank
{
 char name[20];
 char time[10];
};
int main()
{
 struct rank s[12];
 int k=1,n;
 while(scanf("%d",&n),n)
 {
  
  int i,j,t,m1,m2,m3=1;
  int a[12]={0};  
  for(i=1;i<=n;i++)
  scanf("%s%s",s[i].name,s[i].time);
  if(k>1) printf("\n");
  for(i=1;i<=n;i++)
  {
   for(j=1;j<=n;j++)
   {
    if(j==i) continue;
    else
    {
     if(strcmp(s[i].time,s[j].time)>0)
     a[i]++;
     if(strcmp(s[i].time,s[j].time)==0)
     if(strcmp(s[i].name,s[j].name)>0)
     a[i]++;
    }
   }
  }
  //for(i=1;i<=n;i++)
  //printf("%d ",a[i]);
   printf("Case #%d\n",k);
   for(i=1;i<=n;i++)
   {
    if(a[i]==0)
    {
    printf("%s %d\n",s[i].name,1);
    m1=i;m2=1;m3++;
    }
    //printf("%d\n",m1);
   }
   t=1;
   while(t<n){
   for(i=1;i<=n;i++)
   {
    if(a[i]==t)
    {
     printf("%s ",s[i].name);
     if(strcmp(s[i].time,s[m1].time)==0)
     {printf("%d\n",m2);m3++;}
     else
     {printf("%d\n",m3);m2=m3;m3++;}
     m1=i;
    }
   }
   t++;
   }
 k++;
 } 
 return 0;
}

//AC

//网上找的感觉不错的代码,能AC

//冒泡排序法
#include<stdio.h>
struct pp
{
 char w[20];
 int shi;
 int fen;
 int shijian;
 int paiming;
};
struct pp ans[11];
struct pp temp;
int main()
{
 int n,i,j,m=1;
 while(scanf("%d",&n)&&n!=0)
 {
     for(i=0;i<n;i++)
     {
      scanf("%s %d:%d",ans[i].w,&ans[i].shi,&ans[i].fen);
      ans[i].shijian=60*ans[i].shi+ans[i].fen;
     }    
     for(i=0;i<n;i++)
     {
         for(j=0;j<n-1-i;j++)
         {
             if(ans[j].shijian>ans[j+1].shijian)
             {
              temp=ans[j];
              ans[j]=ans[j+1];
              ans[j+1]=temp;
             }//整个结构体互换
         }
      }//冒泡排序
      ans[0].paiming=1;
      for(i=1;i<n;i++)
      {
         if(ans[i-1].shijian==ans[i].shijian)
         ans[i].paiming=ans[i-1].paiming;
         else
         ans[i].paiming=i+1;
      }//排名次
      if(m!=1)
      printf("\n");
      printf("Case #%d\n",m++);
      for(i=0;i<n;i++)
      printf("%s %d\n",ans[i].w,ans[i].paiming);
      /*
      if(k!=1)printf("\n"); 
      printf("Case #%d\n",k++);
      for(i=0;i<n;i++) 
      { 
          if(i>=1&&d[i].tim==d[i-1].tim) 
          {d[i].num=d[i-1].num;} 
          else 
          {d[i].num=i+1;} 
          printf("%s %d\n",d[i].name,d[i].num); 
      } 
      */
 }
 return 0;
}

【ACM】hdu_2115_I Love This Game_201308021517的更多相关文章

  1. 高手看了,感觉惨不忍睹——关于“【ACM】杭电ACM题一直WA求高手看看代码”

    按 被中科大软件学院二年级研究生 HCOONa 骂为“误人子弟”之后(见:<中科大的那位,敢更不要脸点么?> ),继续“误人子弟”. 问题: 题目:(感谢 王爱学志 网友对题目给出的翻译) ...

  2. 【ACM】HDU1008 Elevator 新手题前后不同的代码版本

    [前言] 很久没有纯粹的写写小代码,偶然想起要回炉再来,就去HDU随便选了个最基础的题,也不记得曾经AC过:最后吃惊的发现,思路完全不一样了,代码风格啥的也有不小的变化.希望是成长了一点点吧.后面定期 ...

  3. 【ACM】魔方十一题

    0. 前言打了两年的百度之星,都没进决赛.我最大的感受就是还是太弱,总结起来就是:人弱就要多做题,人傻就要多做题.题目还是按照分类做可能效果比较好,因此,就有了做几个系列的计划.这是系列中的第一个,解 ...

  4. 【ACM】那些年,我们挖(WA)过的最短路

    不定时更新博客,该博客仅仅是一篇关于最短路的题集,题目顺序随机. 算法思想什么的,我就随便说(复)说(制)咯: Dijkstra算法:以起始点为中心向外层层扩展,直到扩展到终点为止.有贪心的意思. 大 ...

  5. 【ACM】不要62 (数位DP)

    题目:http://acm.acmcoder.com/showproblem.php?pid=2089 杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer).杭州交通管理局经常会扩充一些的士车牌照,新 ...

  6. 【Acm】八皇后问题

    八皇后问题,是一个古老而著名的问题,是回溯算法的典型例题. 其解决办法和我以前发过的[算法之美—Fire Net:www.cnblogs.com/lcw/p/3159414.html]类似 题目:在8 ...

  7. 【ACM】hud1166 敌兵布阵(线段树)

    经验: cout 特别慢 如果要求速度 全部用 printf !!! 在学习线段树 内容来自:http://www.cnblogs.com/shuaiwhu/archive/2012/04/22/24 ...

  8. 【acm】杀人游戏(hdu2211)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2211 杀人游戏 Time Limit: 3000/1000 MS (Java/Others)    M ...

  9. 【ACM】How many prime numbers

    http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=2&sectionid=1&problemid=2 #inclu ...

随机推荐

  1. 修改android系统开机动画

    本文转载自:http://blog.csdn.net/u012301841/article/details/51598115 修改android系统开机动画

  2. Android热更新实现原理

    最近Android社区的氛围很不错嘛,连续放出一系列的android动态加载插件和热更新库,这篇文章就来介绍一下Android中实现热更新的原理. ClassLoader 我们知道Java在运行时加载 ...

  3. UESTC--1252--24点游戏(dfs)

     24点游戏 Time Limit: 1000MS   Memory Limit: 65535KB   64bit IO Format: %lld & %llu Submit Status ...

  4. OSGI依赖问题处理

    用osgi实现java的模块化和热插拔时要考虑好两个问题,不同bundle间如何通信?依赖怎么处理? OSGi的一个标准就是各个bundle之间是相互隔离的,每个bundle都有自己的classloa ...

  5. poj1041 John's trip——字典序欧拉回路

    题目:http://poj.org/problem?id=1041 求字典序欧拉回路: 首先,如果图是欧拉图,就一定存在欧拉回路,直接 dfs 即可,不用 return 判断什么的,否则TLE... ...

  6. 92. extjs specialkey监听回车按键

    转自:http://blog.sina.com.cn/s/blog_647a022e0101401n.html 1 监听表单字段事件: Ext使得对用户某个动作的监听特别简单,诸如单击某个元素或者按下 ...

  7. Cracking the Coding Interview 8.7

    Given a infinite number of quarters(25cents), dimens(10cents), nickels(5cents) and pennies(1cent), w ...

  8. 微信图片不可显示java解决方法

    先看知乎:https://www.zhihu.com/question/35044484 场景: 微信上传了图片素材,返回了图片url,然后不能在img标签中正常显示. 原因是微信做了图片防盗连接. ...

  9. Oracle 循环调用存储过程

    create or replace procedure p_test_loop as --定义一个游标,并将查询结果集赋值给它 CURSOR c1 IS select * from tbltest w ...

  10. 金立 M6 (GN8003) 解锁 BootLoader 进入第三方 recovery 刷机 ROOT

    首先下载好工具:http://url.cn/5EILbQn 备用连接 :http://pan.baidu.com/s/1c28j7k0 本篇教程教你如何傻瓜式解锁BootLoader并刷入recove ...