有一个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. 六种流行的语言大餐---C、C++、python、Java、php、C#你更喜欢哪一个呢?

    引言 鉴于五一期间超大的人流量,LZ思来想去,最终还是选择蜗居在自己的出租屋.无聊之际,当然不能忘了做点什么事情,于是LZ就研究了一下几种语言的皮毛,在这里献丑一翻,希望各位猿友莫要见笑. 不过说来也 ...

  2. 使用maven&&make-distribution.sh编译打包spark源码

    1>基础环境准备: jdk1.8.0_101 maven 3.3.9scala2.11.8 安装好上述软件,配置好环境变量,并检查是否生效. 2>配置maven:intellij idea ...

  3. JAVA之运算符优先级

    Java运算符优先级从高到低 运算符 结合性 [ ] . ( ) (方法调用) 从左向右 ! ~ ++ -- +(一元运算) -(一元运算) 从右向左 * / % 从左向右 + - 从左向右 < ...

  4. MAC node + git + bower 简单安装

    一 node 安装 打开https://nodejs.org/en/ nodejs官网 下载安装文件 双击.pkg 文件 自动安装即可 二 安装git 打开 http://code.google.co ...

  5. 解决k8s出现pod服务一直处于ContainerCreating状态的问题的过程

    参考于: https://blog.csdn.net/learner198461/article/details/78036854 https://liyang.pro/solve-k8s-pod-c ...

  6. Golang 2018.1.2激活及使用技巧

    对于做Java开发的同学使用最熟练的开发工具应该当属Eclipse了吧,但是做到后面的话一般都会转用Intellij Idea.至于转用Intellij有什么好处我就不赘述了,简言之就是功能强大,使用 ...

  7. dp算法之有代价的最短路径

    题目:有代价的最短路径 题目介绍:如下图所示,现在平面上有N个点,此时N=7,每个点可能和其他点相连,相连的线有一定权值,求出从0点到N-1点的消耗权值的最小值. 分析:用动态规划的思路来解决,每一点 ...

  8. MyBatis学习(一)————纯jdbc编程

    什么是JDBC  JDBC(Java Data Base Connectivity,java数据库连接)是一种用于执行SQL语句的Java API,可以为多种关系数据库提供统一访问,它由一组用Java ...

  9. [leetcode-921-Minimum Add to Make Parentheses Valid]

    Given a string S of '(' and ')' parentheses, we add the minimum number of parentheses ( '(' or ')', ...

  10. 第一章 HTML介绍

    1.1 Html和CSS的关系 学习web前端开发基础技术需要掌握:HTML.CSS.JavaScript语言.下面我们就来了解下这三门技术都是用来实现什么的: 1. HTML是网页内容的载体.内容就 ...