URAL 1969. Hong Kong Tram
有一个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的更多相关文章
- 每日英语: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 ...
- 每日英语:Hong Kong Lifestyle Strains City's Resources
Hong Kong's rapacious consumption and waste production is straining its natural resources and could ...
- 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 ...
- Asia Hong Kong Regional Contest 2016
A. Colourful Graph 可以在$2n$步之内实现交换任意两个点的颜色,然后就可以构造出方案. #include <bits/stdc++.h> using namespace ...
- Hong Kong Regional Online Preliminary 2016 C. Classrooms
Classrooms 传送门 The new semester is about to begin, and finding classrooms for orientation activities ...
- 2019-2020 ICPC Asia Hong Kong Regional Contest
题解: https://files.cnblogs.com/files/clrs97/19HKEditorial-V1.zip Code:(Part) A. Axis of Symmetry #inc ...
- Asia Hong Kong Regional Contest 2019
A. Axis of Symmetry B. Binary Tree n 的奇偶性决定胜负. C. Constructing Ranches 路径上点权之和大于,极大值两倍,这是路径上点能拼出多边形的 ...
- 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) ...
- URAL 1970 J - 皇后像廣場 dfs
J - 皇后像廣場 题目连接: http://acm.hust.edu.cn/vjudge/contest/123332#problem/J Description Vova was walking ...
随机推荐
- MySQL数据库查询某个库下有几张数据表
如果统计某数据库中存在多少张数据表,使用如下SQL检索语句即可: SELECT COUNT(*) TABLES, table_schema FROM information_schema.TABLES ...
- $.post(url,[data],[callback],'json')
$.post(url,[data],[callback],'json')这个写法来做到用post方法传递数据,并取加回json型数据.如果我要取回的数据类型是xml的,就可以写成$.post(url, ...
- Vue渲染数据理解以及Vue指令
一.Vue渲染数据原理 原生JS改变页面数据,必须要获取页面节点,也即是进行DOM操作,jQuery之类的框架只是简化DOM操作的写法,实质并没有改变操作页面数据的底层原理,DOM操作影响性能(导致浏 ...
- [WPF]解决模板中ContextMenu绑定CommandParameter的问题
直接上代码,首先是一个ContextMenu的模板: <ContextMenu x:Key="Menu" BorderThickness="0.3" Fo ...
- docker 一篇文章学习容器化
什么是镜像?什么是容器? 一句话回答:镜像是类,容器是实例 docker 基本操作命令: 删除所有container: docker rm $(docker ps -a -q) 删 ...
- 廖雪峰git教程学习笔记3
commit是一串不便记忆的数字,为了方便记忆,引入tag,tag就跟HEAD一样,就像一个指针,指向commit,且指向是不能变得,一个commit就有一个tag 给当前分支下的当前commit打上 ...
- valgrind使用简介
1.问题 虽然C/C++是一种非常有用且功能强大的语言,但很难调试. 某些时候可能遇到内存错误. 如果知道出错 ,或者程序一直崩溃,我们可以用gdb/DBX去调试. 但是,有时遇到的问题是由于内存错误 ...
- ubuntu HackRF One相关环境搭建
本文内容.开发板及配件仅限用于学校或科研院所开展科研实验! 淘宝店铺名称:开源SDR实验室 HackRF链接:https://item.taobao.com/item.htm?spm=a1z10.1- ...
- 2019第十届蓝桥杯C++B组题解(赛后重写的,不确保答案正确性,仅供参考)
先说一下这次的感受吧,我们考场比较乱,开始比赛了,还有的电脑有故障,(向这些人发出同情),第一次认真参加比赛,真正比赛的时候感觉没有那么正式,很乱,各种小问题,(例如博主就没找到题目在哪里,找到后又不 ...
- Playfair加密
前面讲的不管是单码加密还是多码加密都属于单图加密,什么是单图加密和多图加密呢,简单来说单图加密就是一个字母加密一个字母,而多图加密就是一个字符组加密一个字符组.比如双图加密就是两个字母加密两个字母,这 ...