fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int n, m, a[200001], b[200001];
  5. long long ca[200001], cb[200001];
  6. long long l[200001], r[200001];
  7.  
  8. int main()
  9. {
  10. int n, m;
  11. cin >> n >> m;
  12. for(int i = 1; i <= n; i++){
  13. cin >> a[i] >> b[i];
  14. ca[a[i]]++;
  15. cb[b[i]]++;
  16. }
  17. for(int i = 0; i <= m; i++)
  18. for(int j = 0; j <= m; j++)
  19. if(i != j) l[i + j] += ca[i] * ca[j], r[i + j] += cb[i] * cb[j];
  20. for(int i = 0; i <= m; i++){
  21. l[i + i] += ca[i] * ca[i];
  22. r[i + i] += cb[i] * cb[i];
  23. }
  24. long long ans = 0;
  25. for(int i = 0; i <= 2*m; i++){
  26. ans += l[i];
  27. cout << ans << endl;
  28. ans -= r[i];
  29. }
  30. }
Success #stdin #stdout 0.01s 9692KB
stdin
2 5
1 3
2 5
stdout
0
0
1
3
4
4
4
3
3
1
1