http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5274

 #include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; int n,l;
char str[];
int ans[];
struct node
{
int h,m,s;
int id;
bool operator <(const node &a)const
{
return (h<a.h)||(h==a.h&&m<a.m)||(h==a.h&&m==a.m&&s<a.s);
}
}p[]; int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&l);
for(int i=; i<n; i++)
{
scanf("%s",str);
p[i].h=(str[]-'')*+(str[]-'');
p[i].m=(str[]-'')*+(str[]-'');
p[i].s=(str[]-'')*+(str[]-'');
p[i].id=i+;
}
sort(p,p+n);
int t1=;
node pos;
/*for(int i=0; i<n; i++)
{
printf("%d %d %d\n",p[i].h,p[i].m,p[i].s);
}*/
for(int i=; i<n; i++)
{
if(i==)
{
ans[t1++]=p[i].id;
pos.s=(p[i].s+l)%;
pos.m=(p[i].m+(p[i].s+l)/)%;
pos.h=p[i].h+((p[i].m+(p[i].s+l)/)/);
}
else
{
//printf("%d %d %d\n",pos.h,pos.m,pos.s);
if(p[i].h>pos.h)
{
ans[t1++]=p[i].id;
pos.s=(p[i].s+l)%;
pos.m=(p[i].m+(p[i].s+l)/)%;
pos.h=p[i].h+((p[i].m+(p[i].s+l)/)/);
}
else if(p[i].h==pos.h&&p[i].m>pos.m)
{
ans[t1++]=p[i].id;
pos.s=(p[i].s+l)%;
pos.m=(p[i].m+(p[i].s+l)/)%;
pos.h=p[i].h+((p[i].m+(p[i].s+l)/)/);
}
else if(p[i].h==pos.h&&p[i].m==pos.m&&p[i].s>pos.s)
{
ans[t1++]=p[i].id;
pos.s=(p[i].s+l)%;
pos.m=(p[i].m+(p[i].s+l)/)%;
pos.h=p[i].h+((p[i].m+(p[i].s+l)/)/);
}
else if(p[i].h==pos.h&&p[i].m==pos.m&&p[i].s==pos.s)
{
ans[t1++]=p[i].id;
pos.s=(p[i].s+l)%;
pos.m=(p[i].m+(p[i].s+l)/)%;
pos.h=p[i].h+((p[i].m+(p[i].s+l)/)/);
}
}
}
printf("%d\n",t1);
sort(ans,ans+t1);
for(int i=; i<t1; i++)
{
if(i==)
{
printf("%d",ans[i]);
}
else
{
printf(" %d",ans[i]);
}
}
printf("\n");
}
return ;
}

zoj 3787 Access System的更多相关文章

  1. ZOJ 3787 Access System 水

    LINK:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3787 思路:结构体 时间转化为秒记录下最小并且排序就好了 /** ...

  2. C++版 - 剑指Offer 面试题45:圆圈中最后剩下的数字(约瑟夫环问题,ZOJ 1088:System Overload类似)题解

    剑指Offer 面试题45:圆圈中最后剩下的数字(约瑟夫环问题) 原书题目:0, 1, - , n-1 这n个数字排成一个圈圈,从数字0开始每次从圆圏里删除第m个数字.求出这个圈圈里剩下的最后一个数字 ...

  3. ZOJ Course Selection System DP

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5565 Course Selection System Time ...

  4. zoj 1409 Communication System

    /*如果要一个物体的多种属性,最好用结构体,不要用二维数组或者多维数组.用多维数组进行关键字排序很不稳定 */ /*给每个设备的所有价格排序,每个设备选取恰好比已知带宽大的价格(这个时候的比例最大) ...

  5. ZOJ 1409 communication system 双变量型的DP

    这个题目一开始不知道如何下手,感觉很像背包,里面有两个变量,一个带宽B,一个价格P,有n个设备,每个设备有k个可选的器材(只需选一个),每个器材都有自己的B和P, n个设备选n个器材,最终,FB=所有 ...

  6. Using Java SecurityManager to grant/deny access to system functions

    In Java it is possible to restrict access to specific functions like reading/writing files and syste ...

  7. Linux File System Change Monitoring Technology、Notifier Technology

    catalog . 为什么要监控文件系统 : hotplug . udev . fanotify(fscking all notification system) . inotify . code e ...

  8. Linux Access.conf安全配置

    access.conf is the configuration file used to logins to the Linux or Unix systems. This file is loca ...

  9. MemoryMappedFile 在 Mono in Linux 的开发笔记

    前言 MemoryMappedFile(简称MMF)类是.NET中对内存映射文件进行操作的类,内存映射文件是非常高效的本地IO方案,由操作系统提供内存与IO文件之间的映射转换,对内存映射文件的更改由操 ...

随机推荐

  1. Python中http请求方法库汇总

    最近在使用python做接口测试,发现python中http请求方法有许多种,今天抽点时间把相关内容整理,分享给大家,具体内容如下所示: 一.python自带库----urllib2 python自带 ...

  2. PhoneGap应用开发的那些坑爹事儿

    子曾经曰过:如果你恨一个人,让他去开发PhoneGap应用:如果你爱一个人,让他去开发PhoneGap应用. 去年这个时候我很烦恼,因为我觉得我OUT了. 起因是我买了一台Android系统的手机.当 ...

  3. Linux下tomcat使用

    http://tomcat.apache.org/download-70.cgi这里下载 放到Linux目录下,解压开, 默认port:8080能够直接使用 经常使用启动命令catalina.sh   ...

  4. searchbar的使用介绍

    searchBar的使用介绍 首先如何创建一个SearchBar实例: self.searchBar = [[UISearchBar alloc] initWithFrame: CGRectMake( ...

  5. Centos清理内存 内存回收释放及内存使用查看的相关命令

    在清理前内存使用情况 free -m 用以下命令清理内存 echo 1 > /proc/sys/vm/drop_caches 清理后内存使用情况再用以下命令看看. free –m 多出很多内存了 ...

  6. HDU 5119 Happy Matt Friends(dp+位运算)

    题意:给定n个数,从中分别取出0个,1个,2个...n个,并把他们异或起来,求大于m个总的取法. 思路:dp,背包思想,考虑第i个数,取或者不取,dp[i][j]表示在第i个数时,异或值为j的所有取法 ...

  7. css.day01.eg

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  8. 将从网上下载下来的javaweb项目继续配置

    1.将下载下来的项目,看有没有报错,这里推荐的是不变成web项目的方法,直接通过编译到服务器目录 2.报错的问题,一般是包,服务器的包,(tomcat-home)指向自己的bin目录 3.然后是添加s ...

  9. (转)PHP中的ob_start用法详解

    用PHP的ob_start();控制您的浏览器cache Output Control 函数可以让你自由控制脚本中数据的输出.它非常地有用,特别是对于:当你想在数据已经输出后,再输出文件头的情况.输出 ...

  10. ExtJs API 下载以及部署

    ExtJs API 下载方法 1.进入sencha官网:https://www.sencha.com/ 2.点击“Docs”进入文档帮助页面:http://docs.sencha.com/ 3.点击左 ...