有一个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. @RestController注解

    @RestController注解其实就是@@Controller和@ResponseBody的组合:RESTFUL风格 看下源码: 当@ResponseBody放到Controller类上,改Con ...

  2. Frida----基本代码

    代码来自官网:https://www.frida.re/docs/examples/android/ import frida, sys def on_message(message, data): ...

  3. 相机标定与矫正opencv+MATLAB

    博客转载自:http://blog.csdn.net/Loser__Wang/article/details/51811347 本文目的在于记录如何使用MATLAB做摄像机标定,并通过opencv进行 ...

  4. selenium的基本定位方式总结

    Selenium提供了8种定位方式. id name class name tag name link text partial link text xpath css selector 这8种定位方 ...

  5. Datawhale MySQL 训练营 Task6 实战项目

    作业 项目十:行程和用户(难度:困难) Trips 表中存所有出租车的行程信息.每段行程有唯一键 Id,Client_Id 和 Driver_Id 是 Users 表中 Users_Id 的外键.St ...

  6. docker node项目 连接mongodb

    在弄docker部署node项目的时候遇到了连接mongdb的问题,记录一下问题解决办法 一.Docker 安装 MongoDB 1.查找Docker Hub上的mongo镜像 [root@VM_49 ...

  7. Spring入门学习笔记(2)——基于Java的配置

    目录 基于Java的配置 @Configuration & @Bean Annotations Example 注入Bean依赖 @Import注解 Lifecycle Callbacks(声 ...

  8. CocoStuff—基于Deeplab训练数据的标定工具【一、翻译】(未完)

    一.CocoStuff简介 CocoStuff是一款为deeplab设计的,运行在Matlab中的语义标定工具,其标定结果和结合Deeplab训练出的结果均为mat文件格式,该项目源码已在github ...

  9. ClassLoader.loadClass()与Class.forName()的区别

    ClassLoader.loadClass()与Class.forName()都是反射用来构造类的方法,但是他们的用法还是有一定区别的. 在讲区别之前,我觉得很有不要把类的加载过程在此整理一下. 在J ...

  10. k倍区间:前缀和

    [蓝桥杯][2017年第八届真题]k倍区间 题目描述 给定一个长度为N的数列,A1, A2, ... AN,如果其中一段连续的子序列Ai, Ai+1, ... Aj(i <= j)之和是K的倍数 ...