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. adb logcat命令查看并过滤android输出log

    cmd命令行中使用adb logcat命令查看android系统和应用的log,dos窗口按ctrl+c中断输出log记录. logcat日志中的优先级/tag标记: android输出的每一条日志都 ...

  2. PHP学习之[第09讲]PHP 的 Mysql 数据库函数 (微型博客系统)

    一.数据库函数: mysql_connect(数据库地址,用户名,密码) mysql_select_db(数据库名) mysql_set_chartset(‘编码’) //PHP5.2.3以后的函数 ...

  3. Scriptcase演示程序

    为了方便大家对Scriptcase有一个非常直观的印象,现在将Scriptcase的示例程序进行了适当汉化,并且放在互联网上,您可以直接点击这个地址访问. 需要说明的是,示例程序中提供的范例,基本上都 ...

  4. [AWS S3] Hosting a Static Website on Amazon S3

    In this lesson, you will learn how to host a static website on Amazon S3. I will show you how to cre ...

  5. TCP/IP源码(59)——TCP中的三个接收队列

    http://blog.chinaunix.net/uid-23629988-id-3482647.html TCP/IP源码(59)——TCP中的三个接收队列  作者:gfree.wind@gmai ...

  6. rsyslog安装

    http://www.rsyslog.com/downloads/download-other/ http://www.rsyslog.com/download/stable-download/pag ...

  7. When does layoutSubviews get called?

    转自:http://blog.logichigh.com/2011/03/16/when-does-layoutsubviews-get-called/ It’s important to optim ...

  8. Android -- 官方下拉刷新SwipeRefreshLayout

    V4的兼容包 API 大概就这4个常用的方法. code 布局 <RelativeLayout xmlns:android="http://schemas.android.com/ap ...

  9. TCP/IP协议原理与应用笔记06:OSI参考模型全称

    1. ISO是一个组织,OSI是一个模型. 2. OSI不是协议,是网络体系结构的概念模型 3. OSI参考模型全称为: Open System Interconnection Reference M ...

  10. css中var函数

    引言: 在学习elementui的时候看到一个var.css, 其中写的全部都是以--开头的属性,上google查询不是css3新增的属性,于是决定一探究竟 :root { /* Transition ...