使用差分
、、、
include[HTML_REMOVED]
using namespace std;
const int N = 2e5 + 5;
int a[N];
int main()
{
int t;
cin >> t;
for(int i = 0; i < t; i)
{
int n;
cin >> n;
memset(a,0,N);
for(int j = 0; j < n; j)
{
int x;
cin >> x;
if(x > j)
{
a[0]–;
a[j + 1];
}
else
{
a[j + 1] ;
a[j - x + 1]–;
}
}
int sum = 0;
for(int k = 0; k < n; k++)
{
sum += a[k];
if(sum < 0)
cout << “1 “;
else
{
cout << “0 “;
}
}
cout << endl;
}
return 0;
}
、、、