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问题了”之类的话.你要知道,大多数人此时 ...
随机推荐
- windows安装node.js加配置淘宝镜像
下载:https://nodejs.org/en/download/ 一路默认,或者选自己的路径,装好后打开cmd, 输入 node --version 显示版本. 是的,环境自己就配置好了! 配置淘 ...
- 浅析领域驱动模型VO、DTO、BO、PO 等的概念、区别及其用法
摘要:浅析POJO.DTO.DO.VO.BO.PO和Entity等的概念.区别及其用法. 名词解释 领域模型中的实体类分为四种模型:VO.DTO.DO和PO,各种实体类用于不同业务层次间的交互,并 ...
- MVVM - Model和ViewModel的创建和配置
MVVM-Model和ViewModel的创建和配置 本文同时为b站WPF课程的笔记,相关示例代码 简介 MVVM:Model-View-ViewModel,是一种软件架构的模式.通过引入一个中间层V ...
- 打开host有感
一年前的呼喊,消失在了文化课的彼端,没有回音: 直至今日打开host,才发觉那时悔恨与泪水的珍贵. [此时此刻的光辉,盼君勿忘]也得加上过去式了啊--
- Windows加域后通过注册表取消壁纸锁定更换壁纸
打开注册表: 开始--运行--regedit (快捷键Win+R) 然后找到HKEY_CURRENT_USER ==> Software ==> Microsoft ==> Wind ...
- Visio画图心得
关于Visio画图时的心得 1.关于对齐 我之前常常是在visio中视图里打开网格,然后根据网格来对齐框框,但是其实网格旁边的参考线用于对齐更好用. 首先,打开在视图选项卡里勾上参考线. 然后因为要根 ...
- 【转载】controller-runtime之manager的实现
介绍 在controller-runtime中使用一个 Manager 的接口来管理 Controller,除了控制器其实还可以管理A dmission Webhook,也包括访问资源对象的clien ...
- js判断一个变量是否存在值得简单方法
在编码过程中,有时候我们需要对一个变量判断其是否有值,这里有一种比较不错的方法判断: !!variable //返回True为存在值,返回False为不存在值 注意是双感叹号"!!" ...
- Java 集合框架底层数据结构实现深度解析
Java 集合框架(Java Collections Framework, JCF)是支撑高效数据处理的核心组件,其底层数据结构的设计直接影响性能与适用场景.本文从线性集合.集合.映射三大体系出发,系 ...
- [CF1672G]Cross Xor
G - Cross Xor 对于\((n\&1)\&\&(m\&1)\)的情况,所有行.列的异或和的必须相等(异或和指当前行/列中所有元素的异或和) 每次修改的点\(( ...