Guest User

Untitled

a guest
Jul 19th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.66 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <iostream>
  3. #include <fstream>
  4. #include <algorithm>
  5. #include <vector>
  6. #include <string>
  7. #include <queue>
  8. #include <map>
  9. #include <set>
  10. #include <cmath>
  11. #include <sstream>
  12. #include <stack>
  13. #include <string.h>
  14.  
  15. #define pb push_back
  16. #define mp make_pair
  17. #define X first
  18. #define Y second
  19. #define PI 3.14159265358979
  20. #define forn(i, n) for(int i = 0; i < n; ++i)
  21. #define ALL(x) x.begin(), x.end()
  22. #define L(s) (int)((s).size())
  23. #define ms(x) memset(x,0,sizeof(x))
  24. #define del(y,x) erase(y.begin()+x)
  25.  
  26. typedef long long ll;
  27. using namespace std;
  28. typedef pair<int,int> pii;
  29. const int INF = 2147483647;
  30. const ll LLINF = 9223372036854775807LL;
  31. const int ST = 100010;
  32. const int ST1 = 1000010;
  33. const ll MOD = 1000000007;
  34.  
  35. ll ABS(ll a)
  36. {
  37.     if(a<0)
  38.         return a*(-1);
  39.     else
  40.         return a;
  41. }
  42.  
  43.  
  44. vector<int> xs;
  45. vector<int> ys;
  46. vector<pii> kor;
  47. map<ll,ll> dig;
  48. vector<ll> lol;
  49. int main()
  50. {
  51. #ifndef ONLINE_JUDGE
  52.     freopen("darts.in", "r", stdin);
  53.     freopen("darts.out", "w", stdout);
  54. #endif
  55.     int n,m,k;
  56.     cin >> n >> m >> k;
  57.     ll ans = 0;
  58.     int x,y;
  59.     for(int i = 0;i < k;i++)
  60.     {
  61.         cin >> x >> y;
  62.         xs.pb(x);
  63.         ys.pb(y);
  64.     }
  65.     xs.pb(0);
  66.     ys.pb(0);
  67.     xs.pb(n);
  68.     ys.pb(m);
  69.     sort(ALL(xs));
  70.     sort(ALL(ys));
  71.     vector<int>::iterator it = unique(ALL(xs));
  72.     xs.resize(it-xs.begin());
  73.     it = unique(ALL(ys));
  74.     ys.resize(it-ys.begin());
  75.  
  76.     for(int i = 0;i < L(xs);i++)
  77.     {
  78.         for(int j = 0;j < L(ys);j++)
  79.         {
  80.             ll l = xs[i]-ys[j];
  81.             lol.pb(l);
  82.         }
  83.     }
  84.     sort(ALL(lol));
  85.     lol.pb(LLINF);
  86.     for(int i = 0;i < L(lol)-1;i++)
  87.     {
  88.         ll k = 0;
  89.         while(lol[i]==lol[i+1])
  90.         {
  91.             i++;
  92.             k++;
  93.         }
  94.         ans+=(1+k)*k/2;
  95.     }
  96.     cout << ans;
  97. }
Add Comment
Please, Sign In to add comment