当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

1868:Antiarithmetic?

题目描述
A permutation of n is a bijective function of the initial n natural numbers: 0, 1, ... n-1. A permutation p is called antiarithmetic if there is no subsequence of it forming an arithmetic progression of length bigger than 2, i.e. there are no three indices 0 <= i < j < k < n such that (pi , pj , pk) forms an arithmetic progression.

For example, the sequence (2, 0, 1, 4, 3) is an antiarithmetic permutation of 5. The sequence (0, 5, 4, 3, 1, 2) is not an antiarithmetic permutation as its first, fifth and sixth term (0, 1, 2) form an arithmetic progression; and so do its second, forth and fifth term (5, 3, 1).

Your task is to check whether a given permutation of n is antiarithmetic.
输入解释
There are several test cases, followed by a line containing 0. Each test case is a line of the input file containing a natural number 3 <= n <= 10000 followed by a colon and then followed by n distinct numbers separated by whitespace. All n numbers are natural numbers smaller than n.
输出解释
For each test case output one line with yes or no stating whether the permutation is antiarithmetic or not.
输入样例
3: 0 2 1 
5: 2 0 1 3 4
6: 2 4 3 5 0 1
0
输出样例
yes
no
yes

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-1868

最后修改于 2020-10-29T06:16:14+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 30000