解析
https://ac.nowcoder.com/acm/discuss/blogs?tagId=266204
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define inf 0x3f3f3f3f
const int mod=1e9+7;
const int N=2e5+5;
int n,m;
int a[N];
void solve(){
cin>>n;
int max1=0,max2=0,id,sum=0;
for(int i=1;i<=n;i++){
cin>>a[i];
sum+=a[i];
if(a[i]>max1){
id=i;
max1=a[i];
}
}
for(int i=1;i<=n;i++){
if(i!=id&&a[i]>max2){
max2=a[i];
}
}
if(n==1){
cout<<1<<endl;
return;
}
for(int i=1;i<=n;i++){
int p=a[i]==max1?max2:max1;
if((sum-a[i]-p)>=p-1){
if(a[i]>(sum-a[i])%2) cout<<1<<" ";
else cout<<0<<" ";
}
else{
if(a[i]>p-(sum-a[i]-p)) cout<<1<<" ";
else cout<<0<<" ";
}
}
cout<<endl;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int tt=1;
cin>>tt;
while(tt--) solve();
return 0;
}