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文件之间的映射转换,对内存映射文件的更改由操 ...
随机推荐
- spring注入成员对象
就是将对象注入到另外一个对象中.这个样例就是有一个学校类,学校类中有一个校长类,最后使用測试文件输出学校类中的信息. 代码结构 学校类 package com.test.SpringGetSet; p ...
- [转] Java中的访问控制
可见/访问性 在同一类中 同一包中 不同包中 同一包子类中 不同包子类中 public yes yes yes yes yes protected yes yes no ...
- 手把手教你从 Core Data 迁移到 Realm
前言 看了这篇文章的标题,也许有些人还不知道Realm是什么,那么我先简单介绍一下这个新生的数据库.号称是用来替代SQLite 和 Core Data的.Realm有以下优点: 使用方便 Realm并 ...
- 《Android开发艺术探索》读书笔记 (13) 第13章 综合技术、第14章 JNI和NDK编程、第15章 Android性能优化
第13章 综合技术 13.1 使用CrashHandler来获取应用的Crash信息 (1)应用发生Crash在所难免,但是如何采集crash信息以供后续开发处理这类问题呢?利用Thread类的set ...
- 自定义控件(视图)2期笔记08:自定义控件之 9patch图说明
1. 何为 9patch图 ? 它是一个对png图片做处理的一个工具,能够为我们生成一个"*.9.png"的图片:所谓"*.9.png"这是Androi ...
- 连接管理VMware SphereESXi
连接管理VMware SphereESXi 1. 准备 下载VMware-viclient-all-5.5.0-1993072,并按照提示安装 2. 使用VMware Sphere Client链接事 ...
- oracle的sql优化
http://www.cnblogs.com/rootq/archive/2008/11/17/1334727.html
- 关于c#流
C#流的简单认识 前言 本篇文章简单总结了在C#编程中经常会用到的一些流.比如说FileStream.MemoryStream. BufferedStream. NetWorkStream. Str ...
- HDU5311
题意:给一个指定的字符串a,要求分成三段,然后再给定另外一个字符串b,要求a中的三段能否在b中找到. 思路:枚举+模拟,首先枚举给定的字符串a,因为分成三段,所以一共有(1+9)*9/2种情况,对于分 ...
- css.day05
1. 外边距合并 不是bug 而是一个特性 (以最大的那个边距为准) 两个盒子是并列关系 两个盒子 父子级关系 1. border 2.overflow:hidden; 3. padding ...