HDU3833 YY's new problem 卡时间第一题
P[i 1]-P[i 2]=P[i 2]-P[i 3], 1<=i 1<i 2<i 3<=N.
InputThe first line is T(T<=60), representing the total test cases.
Each test case comes two lines, the former one is N, 3<=N<=10000, the latter is a permutation of 1 to N.OutputFor each test case, just output 'Y' if such i 1, i 2, i 3 can be found, else 'N'.Sample Input
2
3
1 3 2
4
3 2 4 1
Sample Output
N
Y
不稍微优化一下很容易超时:
# include<iostream>
# include<cstdio>
# include<string.h>
# include<algorithm>
using namespace std;
int vis[],a[];
int main()
{
int i,j,n,T;
scanf("%d",&T);
while(T--){
memset(vis,,sizeof(vis));
bool flag=false;
scanf("%d",&n);
for(i=;i<=n;i++)scanf("%d",&a[i]);
for(i=;i<=n&&!flag;i++){
vis[a[i]]=;
for(j=;j<a[i];j++) {
if(j+a[i]<=n&&vis[a[i]-j]+vis[a[i]+j]==){
flag=true;
break;
}
}
}
if(flag) printf("Y\n");
else printf("N\n");
}
return ;
}
HDU3833 YY's new problem 卡时间第一题的更多相关文章
- Leetcode 春季打卡活动 第一题:225. 用队列实现栈
Leetcode 春季打卡活动 第一题:225. 用队列实现栈 Leetcode 春季打卡活动 第一题:225. 用队列实现栈 解题思路 这里用了非常简单的思路,就是在push函数上做点操作,让队头总 ...
- hdu-3833 YY's new problem(数组标记)
http://acm.hdu.edu.cn/showproblem.php?pid=3833 做这题时是因为我在网上找杭电的数论题然后看到说这道题是数论题就点开看了以下. 然后去杭电上做,暴力,超时了 ...
- HDU1496 Equations 卡时间第二题
Consider equations having the following form: a*x1^2+b*x2^2+c*x3^2+d*x4^2=0 a, b, c, d are integers ...
- Problem B: 时间和日期类(III)
Problem B: 时间和日期类(III) Time Limit: 4 Sec Memory Limit: 128 MBSubmit: 2889 Solved: 1732[Submit][Sta ...
- HDU 3833 YY's new problem ()
YY's new problem Time Limit: 12000/4000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
- 浩顺晶密K-5 打卡时间设置
公司有一台浩顺晶密K-5打卡设备,因为时间异常需要重新调整,设备外部就几个按钮,全部按了一遍发现没有任何变化,所以肯定是哪里操作不对,然后用钥匙打开这个设置,上面有一排文字,分别是设置.+.-.确认等 ...
- HDU 5832 A water problem(某水题)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
- python解无忧公主的数学时间编程题001.py
python解无忧公主的数学时间编程题001.py """ python解无忧公主的数学时间编程题001.py http://mp.weixin.qq.com/s?__b ...
- 《学习OpenCV》练习题第五章第一题ab
这道题是载入一幅带有有趣纹理的图像并用不同的模板(窗口,核)大小做高斯模糊(高斯平滑),然后比较用5*5大小的窗口平滑图像两次和用11*11大小的窗口平滑图像一次是否接近相同. 先说下我的做法,a部分 ...
随机推荐
- 解题报告:codeforce 7C Line
codeforce 7C C. Line time limit per test1 second memory limit per test256 megabytes A line on the pl ...
- Angular for TypeScript 语法快速指南 (基于2.0.0版本)
引导 import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; platformBrowserDynami ...
- CentOS开端口问题
关闭SELINUX ##查看SELINUX状态 /usr/sbin/sestatus -v getenforce #修改config配置文件,重启后即可 vi /etc/selinux/config ...
- HDU 4825 Trie树 异或树!
Xor Sum Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 132768/132768 K (Java/Others)Total S ...
- opencv 图片降噪
—— # -*- coding: utf-8 -* import numpy as np import cv2 cap = cv2.VideoCapture(0) while True: _ , fr ...
- python2 commands模块在python3.x被subprocess取代
subprocess 可以执行shell命令的相关模块和函数有: os.systemos.spawnos.popen --废弃popen2.* --废弃commands.* --废弃,3.x中被移除 ...
- 【待填坑】ajax问题
原生xhr怎么写? 怎么处理回调? 问:http状态码常见有哪些? 问:302是啥?304是啥?什么时候会返回304?你刚刚说浏览器缓存,具体缓存机制是怎么样的? 问:你刚刚说的是发起一个get请求, ...
- pycharm debug
1 debug 的模式,只有在打断点是才能运行. 2 主方法运行的时候 ,可以在下面输入一行 a =1 .方便debug 打完断电的会出现三角头, 运行甲壳虫 3 一步一步运行, F8 , 当 ...
- Apache编译安装
1.准备好源码包并配置好yum源,需要的源码包包括:httpd-2.4.18.apr-1.5.2.tar.gz.apr-util-1.5.4.tar.gz 2.准备用户 groupadd -r apa ...
- spring --解析自定义注解SpringAOP(配合@Aspect)
1:首先,声明自定义注解 @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD}) public @interface DtT ...