1.题目介绍
2.考察点,难度
模拟现实类,数组操作,难度易
3.解题代码
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
int K, n;
scanf("%d", &K);
for (int i = 0; i < K; i++){
bool issolution = true;
scanf("%d", &n);
int seq[n+1] = {0};
for (int j = 1; j < n+1; j++) scanf("%d", seq+j);
for (int j = 1; j < n+1 && issolution; j++){
for (int k = 1; k < j; k++){
if (seq[j] == seq[k] || abs(seq[j]-seq[k]) == abs(j-k)){
issolution = false;
break;
}
}
}
printf("%s", issolution ? "YES\n" : "NO\n");
}
return 0;
}