#include <iostream>
#include <algorithm>
using namespace std;
int seq[1020],vis[1020];
bool judge(int N){
fill(vis,vis+1020,0);
for(int i=1;i<=N;i++){
if(vis[seq[i]]) return false;
vis[seq[i]]=true;
for(int j=i+1;j<=N;j++){
if(abs(j-i)==abs(seq[j]-seq[i])) return false;
}
}
return true;
}
int main(){
int K,num;
scanf("%d",&K);
while(K--){
scanf("%d",&num);
for(int i=1;i<=num;i++){
scanf("%d",&seq[i]);
}
if(judge(num)) printf("YES\n");
else printf("NO\n");
}
return 0;
}
PAT A1128
最新推荐文章于 2021-02-04 21:37:13 发布