The Halting Problem Gym - 102680C
https://vjudge.net/problem/Gym-102680C/origin
https://vjudge.net/contest/396206#problem/C
In the deterministic land of Babbalon, founded by Charles Babbage, of course, all cars have been replaced by fully-autonomous, Turing-complete driving machines. For safety reasons, the two driving machines will never be in the same intersection at the same time, and a machine will halt before an intersection if there is another machine in that intersection. Babbage, late to his afternoon meeting with Mrs. Lovelace, would like to know whether any of the driving machines will stop before going through an intersection.
If nn driving machines each take ss seconds to pass through an intersection, each one arriving at time titi, will any machines have to stop before crossing the intersection?
The times the driving machines will arrive at the intersection will not necessarily be inputted in chronological order. A machine will not halt if it reaches the intersection at the exact same that time another leaves it.
Input
The first line will contain a single integer TT, the number of test cases
The first line of each test case will contain two integers, nn and ss, the number of driving machines and the number of seconds it takes any driving machine to get through the intersection.
The following line contains nn integers, titi, the time in seconds that the iith car arrives at the intersection
0≤T≤400≤T≤40
0≤n,s≤1000≤n,s≤100
0≤ti≤10000≤ti≤1000
Output
Output TT lines, each containing either "YES" if at least one driving machine will have to halt, or "NO" otherwise.
Example
2
3 3
1 4 10
2 5
4 0
NO
YES
Note
For the first test case, driving machines will arrive at times 1, 4, and 10, and take 3 seconds to get through. No machine will have to wait for its turn, so we output "NO".
For the second test case, a driving machine that arrives at time 0 will occupy the intersection up to, but not including, time 5. When another driving machine arrives at time 4, it will have to wait, so we output "YES".
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include <vector>
#include <iterator>
#include <utility>
#include <sstream>
#include <limits>
#include <numeric>
#include <functional>
using namespace std;
#define gc getchar()
#define mem(a) memset(a,0,sizeof(a))
#define debug(x) cout<<"debug:"<<#x<<" = "<<x<<endl; #define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef char ch;
typedef double db; const double PI=acos(-1.0);
const double eps=1e-6;
const int inf=0x3f3f3f3f;
//const int maxn=1e5+10;
const int maxn = 5010;
//const int maxm=100+10;
const int N=1e6+10;
const int mod=1e9+7; int aT[105];
int main()
{ int T = 0;
cin >> T;
while(T--)
{
int n = 0;
int tTC = 0;
cin >> n >> tTC; for(int i = 0;i<n;i++)
{
cin >> aT[i];
}
sort(aT , aT+n); int tell = 0;
for (int i = 0;i<n-1;i++)
{
if (aT[i+1] - aT[i] < tTC) {
tell = 1;
continue;
}
}
if(tell) cout << "YES" << endl;
else cout << "NO" << endl;
} }
The Halting Problem Gym - 102680C的更多相关文章
- The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online -C:Halting Problem(模拟)
C Halting Problem In computability theory, the halting problem is the problem of determining, from a ...
- Halting Problem
Halting Problem: 传送门:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4049 总结一个小规律:题目中给的 ...
- 不可解问题之停机问题(Undecidable Problem Halting Problem)
计算机技术已运用到人类生活的方方面面,帮助人类解决各种问题.可你是否有想过,计算机是否能为人类解决所有问题呢? 假如你是一个程序猿,你已编写过很多程序.有些程序一下子就能出结果,有些程序则好久都没有显 ...
- 停机问题(英语:halting problem)是逻辑数学中可计算性理论的一个问题。通俗地说,停机问题就是判断任意一个程序是否能在有限的时间之内结束运行的问题。该问题等价于如下的判定问题:是否存在一个程序P,对于任意输入的程序w,能够判断w会在有限时间内结束或者死循环。
htps://baike.baidu.com/item/停机问题/4131067?fr=aladdin 理发师悖论:村子里有个理发师,这个理发师有条原则是,对于村里所有人,当且仅当这个人不自己理发,理 ...
- Gym - 102307D Do Not Try This Problem
Do Not Try This Problem Gym - 102307D 题意:给个长度为len的字符串(len<=1e5),然后q次操作(q<=1e5),每次给出i,a,k,c,(i ...
- NP问题/NP完全问题(NP-complete problem)如何判断是否是NP完全问题
在算法复杂度分析的过程中,人们常常用特定的函数来描述目标算法,随着变量n的增长,时间或者空间消耗的增长曲线,近而进一步分析算法的可行性(有效性). 引入了Big-O,Big-Ω,来描述目标算法的上限. ...
- 转载 什么是P问题、NP问题和NPC问题
原文地址http://www.matrix67.com/blog/archives/105 这或许是众多OIer最大的误区之一. 你会经常看到网上出现“这怎么做,这不是NP问题吗”.“这个只有搜 ...
- P和NP问题
1. 通俗详细地讲解什么是P和NP问题 http://blog.sciencenet.cn/blog-327757-531546.html NP----非定常多项式(英语:non-determin ...
- P问题、NP问题、NPC问题、NP难问题的概念
P问题.NP问题.NPC问题.NP难问题的概念 离入职尚有几天时间,闲来无事,将大家常见却又很容易搞糊涂的几个概念进行整理,希望对大家有所帮助.你会经常看到网上出现“这怎么做,这不是NP问题吗”.“这 ...
- P问题、NP问题和NPC问题
P问题.NP问题和NPC问题 这或许是众多OIer最大的误区之一. 你会经常看到网上出现“这怎么做,这不是NP问题吗”.“这个只有搜了,这已经被证明是NP问题了”之类的话.你要知道,大多数人此时 ...
随机推荐
- C#网络编程(六)----Socket编程模型
简介 Socket(套接字)是计算机网络中的一套编程接口,是网络编程的核心,它将复杂的网络协议封装为简单的API,是应用层(HTTP)与传输层(TCP)之间的桥梁. 应用程序通过调用Socket AP ...
- 为Feign客户端自定义ErrorDecoder
摘要:重写Feign的错误解码器ErrorDecoder,以自定义业务逻辑. ErrorDecoder,顾名思义,它是发生错误或者异常情况时使用的一种解码器,允许我们对异常进行特殊处理. 在配 ...
- 利用Word制作Kindle用的6寸PDF电纸书
在word中以自己喜好的字体.字形和行间距等排版,完成后设置布局: 页面(纸张)大小自定义为宽X高=9cm X 12cm 页边距设为4个0.5cm 不要插入页码,占空间 另存为PDF 导入kind ...
- CF1988D The Omnipotent Monster Killer
CF1988D The Omnipotent Monster Killer 本文同步于我的网站. Problem 怪物们在一棵有 \(n\) 个顶点的树上,编号为 \(i(1\le i\le n)\) ...
- Hypermesh_LsDyna划分网格
1.创建角点 2.创建单元(按F6) 3.划分网格(按F12) 4.清除临时节点(Geom → temp nodes → clear all) 5.设置单元集(PD单元)(*SET_SHELL_LIS ...
- 构建RPM之SPEC详解
一.简单说明 在centos/rhel的系统使用中,我们会涉及自己构建一些rpm包在centos/rhel的系统中进行安装,这里涉及rpm打包环境的部署.SPEC文件的编写相关,下面我们具体进行说明. ...
- mysql字符集插入中文报错
org.apache.ibatis.exceptions.PersistenceException: ### Error updating database. Cause: java.sql.SQLE ...
- 使用Oracle数据库的递归查询语句生成菜单树
SQL 格式 SELECT * FROM TABLE WHERE [...结果过滤语句] START WITH [...递归开始条件] CONNECT BY PRIOR [...递归执行条件] 查询所 ...
- 数栈技术分享:OTS数据迁移——我们不生产数据,我们是大数据的搬运工
数栈是云原生-站式数据中台PaaS,我们在github和gitee上有一个有趣的开源项目:FlinkX,FlinkX是一个基于Flink的批流统一的数据同步工具,既可以采集静态的数据,也可以采集实时变 ...
- 100万QPS短链系统如何设计?
前言 凌晨两点,监控大屏突然飙红--短链服务QPS突破80万! 数据库连接池告急,Redis集群响应延迟突破500ms. 这不是演习,而是某电商平台大促的真实场景. 当每秒百万级请求涌向你的短链服务, ...