#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include <set>
using namespace std;
int main()
{
int M,N,a;
cin >> M;
for (int k = 0; k < M; k++)
{
cin >> N;
vector<int> v(N);
bool flag = false;
for (int i = 0; i < N; i++)
{
cin >> v[i];
for (int j = 0; j < i; j++)
{
if (abs(i - j) == abs(v[i] - v[j]) || abs(v[i] - v[j]) == 0)
{
cout << "NO" << endl;
flag = true;
while (cin.get()!='\n')//丢弃未输入的数据
{
cin >> a;
}
break;
}
}
if (flag == true)
break;
}
if (flag == false) cout << "YES" << endl;
}
system("pause");
return 0;
}
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include <set>
using namespace std;
int main()
{
int M,N;
cin >> M;
for (int k = 0; k < M; k++)
{
cin >> N;
vector<int> v(N);
bool flag = false;
for (int i = 0; i < N; i++)
{
cin >> v[i];
for (int j = 0; j < i; j++)
{
if (abs(i - j) == abs(v[i] - v[j]) || abs(v[i] - v[j]) == 0)
{
flag = true;
break;
}
}
}
if (flag == false) cout << "YES" << endl;
else cout << "NO" << endl;
}
system("pause");
return 0;
}
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include <set>
using namespace std;
int main()
{
int M,N,a;
vector<int> v;
cin >> M;
for (int i = 0; i < M; i++)
{
cin >> N;
v.clear();
for (int j = 0; j < N; j++)
{
cin >> a;
v.push_back(a);
}
bool flag = false;
for (int i = 0; i < v.size(); i++)
{
for (int j = i+1; j < v.size(); j++)
{
if (abs(i - j) == abs(v[i] - v[j]) || abs(v[i]-v[j])==0)
{
cout << "NO" << endl;
//cout << "i=" << i << " j=" << j << endl;
flag = true;
break;
}
}
if (flag==true) break;
}
if (flag == false) cout << "YES" << endl;
}
system("pause");
return 0;
}
网友评论