有一个trick就是没想到,枚举第二段时间后,要检测该火车能否继续跑一圈来判断,不能先检测前半圈能不能跑加进去后在检测后半段;

// **** 部分不能放在那个位置;

最近代码导致的错误总是找不出,贴下代码权当提醒吧!!

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<algorithm>
using namespace std;
int us[];
int ID[];
vector<int> pr[];
int ti[];
int n;
void FIND(int i,int x,int nn,int y){
int pt = ti[i] - x;
pr[nn].clear();
pr[nn].push_back(ti[i] - x);
while ( true )
{
int nt = pt + x;
if ( ID[nt] == - ) break;
us[nt] = ;
// pr[nn].push_back(pt + x + y); ****
nt = nt + y + y;
if (ID[nt] == -) break;
us[nt] = ; pr[nn].push_back(pt + x + y);
pr[nn].push_back(pt + x + y + y + x);
pt = pt + y * + x + x;
}
}
int work(int x,int y) {
memset(us, , sizeof us);
pr[].clear();
int mm = ;
us[ti[]] = ;
FIND(,x,,y);
int nn = ;
mm = pr[].size();
if ( (mm - ) % ) return ;
for ( int i = ; i < n; i ++ )
{
if ( us[ti[i]] ) continue;
us[i] = ;
FIND(i,x,nn,y);
nn ++;
if ( pr[nn-].size() != mm ) return false;
}
if (pr[][] <= pr[nn-][]) return ; for (int i = ; i < nn; i++) {
int sz = pr[i].size();
for (int j = ; j < sz; j++) {
int hh,mm,ss;
hh = pr[i][j] / ;
mm = pr[i][j] % / ;
ss = pr[i][j] % % ;
printf("%02d:%02d:%02d%c",hh,mm,ss, j == sz- ? '\n':' ');
}
}
return ;
}
void solve(){
for (int k = ; k < n; k++) {
int tx = ti[] - ti[], ty = ti[k] - ti[];
if (ty % ) continue;
if (work(tx,ty/)) return;
}
// cout<<" ** "<< endl;
}
int main(){
// freopen("in.txt","r",stdin);
n = ;
int hh,mm,ss;
memset(ID,-,sizeof(ID));
while (~scanf("%d:%d:%d",&hh,&mm,&ss)) {
ti[n++] = hh * + mm * + ss;
ID[ti[n-]] = n-;
}
// cout<<" ** "<<endl;
solve();
return ;
}

URAL 1969. Hong Kong Tram的更多相关文章

  1. 每日英语:Google Scraps Plan to Build Hong Kong Data Center

    Internet giant Google Inc. has scrapped a plan to build its own data center in Hong Kong and will in ...

  2. 每日英语:Hong Kong Lifestyle Strains City's Resources

    Hong Kong's rapacious consumption and waste production is straining its natural resources and could ...

  3. Neon Lights in Hong Kong【香港霓虹灯】

    Neon Lights in Hong Kong Neon is to Hong Kong as red phone booths are to London and fog is to San Fr ...

  4. Asia Hong Kong Regional Contest 2016

    A. Colourful Graph 可以在$2n$步之内实现交换任意两个点的颜色,然后就可以构造出方案. #include <bits/stdc++.h> using namespace ...

  5. Hong Kong Regional Online Preliminary 2016 C. Classrooms

    Classrooms 传送门 The new semester is about to begin, and finding classrooms for orientation activities ...

  6. 2019-2020 ICPC Asia Hong Kong Regional Contest

    题解: https://files.cnblogs.com/files/clrs97/19HKEditorial-V1.zip Code:(Part) A. Axis of Symmetry #inc ...

  7. Asia Hong Kong Regional Contest 2019

    A. Axis of Symmetry B. Binary Tree n 的奇偶性决定胜负. C. Constructing Ranches 路径上点权之和大于,极大值两倍,这是路径上点能拼出多边形的 ...

  8. 2019-2020 ICPC Asia Hong Kong Regional Contest J. Junior Mathematician 题解(数位dp)

    题目链接 题目大意 要你在[l,r]中找到有多少个数满足\(x\equiv f(x)(mod\; m)\) \(f(x)=\sum_{i=1}^{k-1} \sum_{j=i+1}^{k}d(x,i) ...

  9. URAL 1970 J - 皇后像廣場 dfs

    J - 皇后像廣場 题目连接: http://acm.hust.edu.cn/vjudge/contest/123332#problem/J Description Vova was walking ...

随机推荐

  1. vs2012调试时,抛出异常的等待时间很慢,原来是QQ电脑管家搞的鬼。

    vs2012调试时,抛出异常的等待时间以前都正常,不知什么时候起变得很慢,就是出错以后要等30秒以上才会提示,一直找不到原因. 今天看了一下任务管理器,发现有个QQpcrTP进程(好像是,因为卸载了) ...

  2. Jmeter介绍1

    要测试的响应字段: 响应文本:即响应的数据,比如json等文本 响应代码:http的响应代码,比如200,302,404这些 响应信息:http响应代码对应的响应信息,列如OK,Found Respo ...

  3. AI 启蒙-无人售货机智能找零算法

    人的理想志向往往和他的能力成正比. --约翰逊--  AI 启蒙-无人售货机智能找零算法  [问题区] 你现在是一家无人售货机生产公司的高级程序员,技术经理叫你实现无人售货机智能找零钱的算法,具体需求 ...

  4. oracle数据库之子查询

    子查询也叫内部查询,在主查询之前执行一次并得到结果,此结果一般情况下,是用来当做是主查询的条件.   -- 在 emp 表中,找出工资比 ALLEN 的高? -- 先查出 ALLEN 的工资是多少? ...

  5. 基于神念TGAM的脑波小车(2)

    将数据处理移植到STM32上,采用串口的DMA接收模式,注意的是DMA_MODE采用Circular,DMA_BufferSize>(8*512+36=4132)(小包8个字节,每秒512个,完 ...

  6. RabbitMQ和Kafka,更加便捷高效的消息队列使用方式,请放心食用

    一.RabbitMQ实例介绍RabbitMQ实例由华为云分布式消息服务(DMS)团队打造,实例采用物理隔离的方式部署,租户独占RabbitMQ实例.一键式部署,完全兼容开源RabbitMQ的使用方式, ...

  7. 进阶:2.GBDT算法梳理

    GBDT算法梳理 学习内容: 1.前向分布算法 2.负梯度拟合 3.损失函数 4.回归 5.二分类,多分类 6.正则化 7.优缺点 8.sklearn参数 9.应用场景 1.前向分布算法 在学习模型时 ...

  8. c++ 整数和字符串的转化

    一.string转int的方式 采用最原始的string, 然后按照十进制的特点进行算术运算得到int,但是这种方式太麻烦,这里不介绍了. 采用标准库中atoi函数. "; int a = ...

  9. Android NDK 工具链的使用方法(Standalone Toolchain)

    转载:http://blog.csdn.net/smfwuxiao/article/details/6587709 首先需要确定目标机器的指令集. 如果是 x86 的机器,用 x86-4.4.3 版本 ...

  10. [奇葩问题] Error Domain=NSURLErrorDomain Code=-1003

    问题描述: 新上线的产品,ios同事拿着一串报错来找我,日志如下:err =Error Domain=NSURLErrorDomain Code=-1003 "未能找到使用指定主机名的服务器 ...