# A. Ahahahahahahahaha SOLUTIONS Codeforces Round #669 (Div. 2)

## Ahahahahahahahaha SOLUTION Codeforces Round #669 (Div. 2)

Alexandra has an even-length cluster a, comprising of 0s and 1s. The components of the exhibit are specified from 1 to n. She needs to eliminate all things considered n2 components (where n — length of cluster) in the way that substituting whole of the exhibit will be equivalent 0 (for example a1−a2+a3−a4+… =0). At the end of the day, Alexandra needs total of all components at the odd positions and whole of all components at the even situations to get equivalent. The components that you eliminate don’t need to be sequential.
For instance, on the off chance that she has a=[1,0,1,0,0,0] and she eliminates second and fourth components, a will become equivalent [1,1,0,0] and its rotating whole is 1−1+0−0=0.
Help her!
Info
Each test contains numerous experiments. The principal line contains the quantity of experiments t (1≤t≤103). Depiction of the experiments follows.
The main line of each experiment contains a solitary number n (2≤n≤103, n is even) — length of the cluster.
The subsequent line contains n numbers a1,a2,… ,a (0≤ai≤1) — components of the exhibit.
It is ensured that the total of n over all experiments doesn’t surpass 103.
Yield
For each experiment, right off the bat, print k (n2≤k≤n) — number of components that will stay subsequent to eliminating as per the pattern in which they show up in a. At that point, print this k numbers. Note that you should print the numbers themselves, not their lists.
We can show that an answer consistently exists. In the event that there are a few answers, you can yield any of them.
Model
inputCopy
4
2
1 0
2
0
4
0 1
4
1 0
outputCopy
1
0
1
0
2
1
4
1 0
Note
In the first and second cases, exchanging aggregate of the exhibit, clearly, approaches 0.
In the third case, rotating total of the cluster rises to 1−1=0.
In the fourth case, exchanging whole as of now approaches 1−1+0−0=0, so we don’t need to eliminate anything.

### 1 thought on “A. Ahahahahahahahaha SOLUTIONS Codeforces Round #669 (Div. 2)”

1. #pragma GCC optimize("Ofast")

#include

#define LLI long long int
#define LD long double
#define PB push_back
#define MP make_pair
#define FORi(i, a, b) for(int i = a; i < b ; ++i)
#define FORd(i, a, b) for(int i = a; i > b ; –i)

using namespace std;

int main(){
int t,n,k,u,v;
vector d1(2000000);
vector d2(2000000);
vector used1_odd,used1_ev,used2_odd,used2_ev;
LLI ans;
cin >> t;
while (t–){
cin >> n >> k;
FORi(i,0,n+n-1)
d1[i]=d2[i]=0;
FORi(i,0,k){
cin >> u >> v;
u–; v–;
d1[u+v]=1;
d2[u-v+n-1]=1;
}
ans=1ll*n*n;
FORi(i,0,n+n-1){
if (d1[i]){
ans-=(i<n?i+1:n+n-1-i);
if (i&1)
used1_odd.PB((i<n?i+1:n+n-1-i));
else
used1_ev.PB((i<n?i+1:n+n-1-i));
}
if (d2[i]){
ans-=(i<n?i+1:n+n-1-i);
if (i&1)
used2_odd.PB((i<n?i+1:n+n-1-i));
else
used2_ev.PB((i<n?i+1:n+n-1-i));
}
}
sort(used2_odd.begin(),used2_odd.end());
sort(used2_ev.begin(),used2_ev.end());
FORi(i,0,used1_odd.size())
if (n&1)
ans+=used2_odd.end()-lower_bound(used2_odd.begin(),used2_odd.end(),n+1-used1_odd[i]);
else
ans+=used2_ev.end()-lower_bound(used2_ev.begin(),used2_ev.end(),n+1-used1_odd[i]);
FORi(i,0,used1_ev.size())
if ((n&1)==0)
ans+=used2_odd.end()-lower_bound(used2_odd.begin(),used2_odd.end(),n+1-used1_ev[i]);
else
ans+=used2_ev.end()-lower_bound(used2_ev.begin(),used2_ev.end(),n+1-used1_ev[i]);
used1_odd.clear();
used1_ev.clear();
used2_odd.clear();
used2_ev.clear();
cout << ans << endl;
}
return 0;
}