感觉这题测试数据好像有点问题吧!
这是我看到有人通过的代码,按照代码的意思,求相邻两点的斜率,求完之后斜率绝对值出现两种或三种就可以找到?这不科学呀,如果呈z字形走(1,0)(2,1)(3,2)(4,3)(5,2)(6,1)(7.,0)(8,1)(9,2)……如此分布 斜率值也只会出现两个,但是画不出两条平行直线使得满足条件,这题的测试数据是不是错了?
#include<bits/stdc++.h>
//#define DEBUG
usingnamespacestd;
typedeflonglongll;
constintMAXN = 2e5 + 5;
set<int>s;
map<int,int> tp;
inta[MAXN];
intmain()
{
#ifndef DEBUG
ios::sync_with_stdio(false);
cin.tie(nullptr);
#endif // DEBUG
intn;
cin >> n;
for(inti = 1; i <= n; i++)
{
cin >> a[i];
}
for(inti = 2; i <= n; i++)
{
intx = a[i] - a[i - 1];
x = abs(x);
s.insert(x);
}
if(s.size() == 2 || s.size() == 3)
{
cout << "QWQ\n";
}
else
{
cout << "QAQ\n";
}
return0;
}