fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int t, n, x, i, p;
  6. cin >> t;
  7. while(t-->0){
  8. cin >> n >> x;
  9. int a[x] = {0};
  10. while(n-->0){
  11. cin >> i;
  12. if(i>x-1) continue;
  13. a[i]++;
  14. }
  15. p=0;
  16. cout << x/2 << endl;
  17. cout << a[3] << ' ' << a[x-3] << endl;
  18. for(i=1; i<=x/2 && (a[i]>0 && a[x-i]>0); ++i){
  19. n = a[x-i];
  20. cout << a[i] << ' ' << n << endl;
  21. if(x==(i<<1)) p += ((n*(n-1))>>1);
  22. else p += a[i]*n;
  23. }
  24. for(i=0; i<x; ++i){
  25. cout << a[i] << ' ';
  26. }
  27. cout << endl;
  28. cout << p << endl;
  29. }
  30. return 0;
  31. }
Success #stdin #stdout 0s 4164KB
stdin
1
49 50
48 24 99 51 33 39 29 83 74 72 22 46 40 51 67 37 78 76 26 28 76 25 10 65 64 47 34 88 26 49 86 73 73 36 75 5 26 4 39 99 27 12 97 67 63 15 3 92 90
stdout
25
1 1
0 0 0 1 1 1 0 0 0 0 1 0 1 0 0 1 0 0 0 0 0 0 1 0 1 1 3 1 1 1 0 0 0 1 1 0 1 1 0 2 1 0 0 0 0 0 1 1 1 1 
0