有一个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. springmvc框架开发常用的注解总结

    1.@Controller使用:表示表现层中的JavaBean被spring容器管理.   2.@requestMapping使用: a) 在方法上: 标记url到请求方法的映射, 就相当于从一个ur ...

  2. 我们一起来聊聊并发吧,one。

    引言 最近工作当中写了一个有关并发的程序,引起了LZ对并发的强烈兴趣.这一下一发不可收拾,LZ用了一个多星期,看完了这本共280+页的并发编程书.之所以能看这么快,其实这主要归功于,自己之前对并发就有 ...

  3. 一个针对string的较好的散列算发djb2

    var djb2HashCode = function(key) { var hash = 5831; for(var i = 0; i < key.length; i++) { hash = ...

  4. 13-调试Dockerfile

    包括 Dockerfile 在内的任何脚本和程序都会出错.有错并不可怕,但必须有办法排查,所以本节讨论如何 debug Dockerfile. 先回顾一下通过 Dockerfile 构建镜像的过程: ...

  5. 学习java常见dos命令

    在java基础学习阶段时一般会在dos命令行下操作文件,这里列出一些常用命令. 打开DOS控制台的方式 按win+r 再输入 cmd 然后回车. 常用DOS命令 d: 回车 盘符切换 (盘符加冒号) ...

  6. oracle表空间的创建及dmp 文件的导入

    --用oracle系统权限的账号 登陆 -- 1.创建用户 create user u_name identified by "u_password"; --2.赋予权限 gran ...

  7. react-native初体验(2) — 认识路由

    如果学习止步于 hello world, 那么人生也太没意思了.这次要做一个看起来真实的应用.多添加几个页面,让他们可以交互,动起来. react-native 官方推荐使用 react-naviga ...

  8. Revit开发-设置对象样式

    最近需要读取RVT项目样板一些对象样式,翻了一下API,查找到下面的情况:

  9. python类与对象的内置函数大全(BIF)

    关于类与对象的一些常用BIF(内置函数) 1.issubclass(class,classinfo) 含义:如果class是classinfo的子类,则返回True,否则返回false,用来判断子类关 ...

  10. python中__name__属性的使用

    python常用模块目录 1.打印出函数名字而非函数名对应的地址 )打印的是函数地址 def func(): print("我是%s函数"%func) func() ------- ...