fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int t;
  6. cin>>t;
  7. while(t--)
  8. {
  9. int n;
  10. cin>>n;
  11. int a[n];
  12. for(int i=0;i<n;i++)
  13. {
  14. cin>>a[i];
  15. }
  16. bool arr[100]={false};
  17. for(int i=0;i<n;i++)
  18. {
  19. if(a[i]==0)
  20. {
  21. for(int j=0;j<n;j++)
  22. arr[j]=0;
  23. }
  24. else
  25. {
  26. arr[a[i]]=!arr[a[i]];
  27. }
  28. }
  29. int count=0;
  30. for(int i=0;i<n;i++)
  31. {
  32. count=count+arr[i];
  33. }
  34. cout<<count;
  35. }
  36. return 0;
  37. }
Success #stdin #stdout 0s 2744KB
stdin
1
7
1 1 2 1 0 2 1
stdout
2