fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5. #include<map>
  6. using namespace std;
  7.  
  8. /**
  9.  * Auto-generated code below aims at helping you parse
  10.  * the standard input according to the problem statement.
  11.  **/
  12.  
  13. int main()
  14. {
  15. int w;
  16. int h;
  17. int count_x;
  18. int count_y;
  19. vector<int>X,Y;
  20. cin >> w >> h >> count_x >> count_y; cin.ignore();
  21. for (int i = 0; i < count_x; i++) {
  22. int x;
  23. cin >> x; cin.ignore();
  24. X.push_back(x);
  25. }
  26. for (int i = 0; i < count_y; i++) {
  27. int y;
  28. cin >> y; cin.ignore();
  29. Y.push_back(y);
  30. }
  31. X.push_back(0);
  32. Y.push_back(0);
  33. X.push_back(w);
  34. int last=0;
  35. Y.push_back(h);
  36. long long ans=0;
  37. vector<pair<int,int>>points;
  38. for (int i=0;i<X.size();i++){
  39. for (int j=0;j<Y.size();j++){
  40. points.push_back({X[i],Y[j]});
  41. }
  42. }
  43. map<int,int>difX;
  44. //get the diffrence between the x cordinates
  45. // h*h
  46. for (int i=0;i<X.size();i++){
  47. for (int j=0;j<X.size();j++){
  48. if (X[i]>X[j]){
  49. difX[X[i]-X[j]]++;
  50. }
  51. }
  52. }
  53. // w*w log2(h*h)
  54. for (int i=0;i<Y.size();i++){
  55. for (int j=0;j<Y.size();j++){
  56. if (Y[i]>Y[j]){
  57. ans+=difX[Y[i]-Y[j]];
  58. }
  59. }
  60. }
  61. cout << ans << endl;
  62. }
Success #stdin #stdout 0.01s 5260KB
stdin
Standard input is empty
stdout
Standard output is empty