简单题
#include<string.h>
#include<string>
#include<iostream>
using namespace std;
int visited[1005][1005];
bool nqueue()
{
string s;
int N;
cin >> N;
memset(visited, 0, sizeof(visited));
for (int t = 1;t <= N;t++)
{
int temp;
cin >> temp;
if (visited[t][temp] == 1)
{
getline(cin, s);
return false;
}
for (int i = t + 1;i <= N;i++)
visited[i][temp] = 1;
for (int i = t + 1;i <= N;i++)
{
if (i - t + temp <= N) visited[i][i - t + temp] = 1;
if (temp - (i - t) >= 1) visited[i][temp - i + t] = 1;
}
}
return true;
}
int main()
{
int N;
cin >> N;
while (N--)
if (nqueue()) cout << "YES" << endl;
else cout << "NO" << endl;
}