zoj 3787 Access System
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的更多相关文章
- ZOJ 3787 Access System 水
LINK:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3787 思路:结构体 时间转化为秒记录下最小并且排序就好了 /** ...
- C++版 - 剑指Offer 面试题45:圆圈中最后剩下的数字(约瑟夫环问题,ZOJ 1088:System Overload类似)题解
剑指Offer 面试题45:圆圈中最后剩下的数字(约瑟夫环问题) 原书题目:0, 1, - , n-1 这n个数字排成一个圈圈,从数字0开始每次从圆圏里删除第m个数字.求出这个圈圈里剩下的最后一个数字 ...
- ZOJ Course Selection System DP
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5565 Course Selection System Time ...
- zoj 1409 Communication System
/*如果要一个物体的多种属性,最好用结构体,不要用二维数组或者多维数组.用多维数组进行关键字排序很不稳定 */ /*给每个设备的所有价格排序,每个设备选取恰好比已知带宽大的价格(这个时候的比例最大) ...
- ZOJ 1409 communication system 双变量型的DP
这个题目一开始不知道如何下手,感觉很像背包,里面有两个变量,一个带宽B,一个价格P,有n个设备,每个设备有k个可选的器材(只需选一个),每个器材都有自己的B和P, n个设备选n个器材,最终,FB=所有 ...
- 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 ...
- Linux File System Change Monitoring Technology、Notifier Technology
catalog . 为什么要监控文件系统 : hotplug . udev . fanotify(fscking all notification system) . inotify . code e ...
- Linux Access.conf安全配置
access.conf is the configuration file used to logins to the Linux or Unix systems. This file is loca ...
- MemoryMappedFile 在 Mono in Linux 的开发笔记
前言 MemoryMappedFile(简称MMF)类是.NET中对内存映射文件进行操作的类,内存映射文件是非常高效的本地IO方案,由操作系统提供内存与IO文件之间的映射转换,对内存映射文件的更改由操 ...
随机推荐
- hive 模块
- centos 7 安装 mariadb数据库
1.安装MariaDB #安装命令yum install mariadb mariadb-server -y#安装完成MariaDB,首先启动MariaDBsystemctl start mariad ...
- cat-mvc 一个nodejs mvc 框架
不多说,自己看,哈哈哈 https://www.npmjs.com/package/cat-mvc
- js提交前弹出提示框
<form target="_blank" name="f1" method="post" action="sub2.php ...
- C#中反射接受的字符串需要满足的Backus-Naur Form语法
MSDN的Specifying Fully Qualified Type Names指明了C#中反射接受的字符串需要满足如下的Backus-Naur Form语法. BNF grammar of fu ...
- crowd在更改IP后无法登录的问题
org.codehaus.xfire.fault.XFireFault: Client with address "192.168.1.222", and hostname &qu ...
- win32程序中简单应用mfc
今日写程序在win32中用CRect发现报错,突然想起来.要引入mfc库.想重新建立一个工程添加对mfc的支持.发现选项不能选.查资料后发现. 在win32程序中简单应用mfc库,只需要简单的引入&l ...
- yii 载入css or js
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . "/js/TableView.js&q ...
- composer 说明<转>
转自 http://blog.csdn.net/zzulp/article/details/18981029 Composer是一个基于项目的依赖管理器,负责将PHP项目所依赖的包或库安装到项目所在 ...
- Python之路,Day4 - Python基础4 (new版)
Python之路,Day4 - Python基础4 (new版) 本节内容 迭代器&生成器 装饰器 Json & pickle 数据序列化 软件目录结构规范 作业:ATM项目开发 ...