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文件之间的映射转换,对内存映射文件的更改由操 ...
随机推荐
- ALS数学点滴
其中,$n_{u_i}$表示用户$i$评分的电影数目,$n_{m_j}$表示对电影$j$评分的用户数目.设$I_i$表示用户$i$所评分的电影集合,则$n_{u_i}$是$I_i$的基数,同样的,$I ...
- [AngularJS] Use ng-model-options to limit $digest
Refer: http://toddmotto.com/super-fast-angular-ng-model-options-limit-digest-cycles/ Use: <input ...
- HDU -2298 Toxophily(三分法)
这道题目,可以推出物理公式直接来做,但是如果推不出来就必须用程序的一种算法来实现了,物理公式只是适合这一个或者某个题,但是这种下面这种解决问题的方法确实解决了一类问题 ----三分法,大家可能都听说过 ...
- niop 2014寻找道路
/* 乍一看就是个最短路 SFPA 但是要保证路径上的所有点的出边所指向的点都直接或间接与终点连通. 这一点就蛋疼了0.0 开始想的是正着跑一边 每一个点的所有边都能符合条件 那这个点就符合条件0.0 ...
- HUD 2444 The Accomodation of Students (二分图染色+最大匹配)
#include<iostream> #include<cstdio> #include<cstring> #define maxn 2010 using name ...
- 进程外session(session保存在sqlserver)
.Session保存在SQLServer中配置方法 )运行.NetFramework安装目录下对应版本的aspnet_regsql.exe 来创建相关的数据库.表和存储过程等,比如: C:\Windo ...
- js实现图片上传及预览---------------------->>兼容ie6-8 火狐以及谷歌
<head runat="server"> <title>图片上传及预览(兼容ie6/7/8 firefox/chrome)</title> & ...
- Linux SSH: key, agent, keychain
以前遇到过一个问题,在用有些 Linux 发行版时,用 ssh-keygen 产生好了密钥对并上传到了目标服务器,但每次登录都要重新输入. 这与 ssh-agent 有关,看如下 man ssh-ag ...
- 前后台使用ajax传list的时候,用value[] 获取值
使用json进行前后台交互的时候,如果穿过来是的是list,可以通过value[index],(index表示的是下标) //加载新闻 function jzxw(){ $.ajax( { type ...
- Java数字、货币值和百分数等的格式化处理
如果我们用下列语句输出一个数 System.out.println(123456.789); 将会在Console看到输出 123456.789 那么如何得到123,456.789这种格式化的输出呢? ...