Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <iostream>
- #include <fstream>
- #include <algorithm>
- #include <vector>
- #include <string>
- #include <queue>
- #include <map>
- #include <set>
- #include <cmath>
- #include <sstream>
- #include <stack>
- #include <string.h>
- #define pb push_back
- #define mp make_pair
- #define X first
- #define Y second
- #define PI 3.14159265358979
- #define forn(i, n) for(int i = 0; i < n; ++i)
- #define ALL(x) x.begin(), x.end()
- #define L(s) (int)((s).size())
- #define ms(x) memset(x,0,sizeof(x))
- #define del(y,x) erase(y.begin()+x)
- typedef long long ll;
- using namespace std;
- typedef pair<int,int> pii;
- const int INF = 2147483647;
- const ll LLINF = 9223372036854775807LL;
- const int ST = 100010;
- const int ST1 = 1000010;
- const ll MOD = 1000000007;
- ll ABS(ll a)
- {
- if(a<0)
- return a*(-1);
- else
- return a;
- }
- vector<int> xs;
- vector<int> ys;
- vector<pii> kor;
- map<ll,ll> dig;
- vector<ll> lol;
- int main()
- {
- #ifndef ONLINE_JUDGE
- freopen("darts.in", "r", stdin);
- freopen("darts.out", "w", stdout);
- #endif
- int n,m,k;
- cin >> n >> m >> k;
- ll ans = 0;
- int x,y;
- for(int i = 0;i < k;i++)
- {
- cin >> x >> y;
- xs.pb(x);
- ys.pb(y);
- }
- xs.pb(0);
- ys.pb(0);
- xs.pb(n);
- ys.pb(m);
- sort(ALL(xs));
- sort(ALL(ys));
- vector<int>::iterator it = unique(ALL(xs));
- xs.resize(it-xs.begin());
- it = unique(ALL(ys));
- ys.resize(it-ys.begin());
- for(int i = 0;i < L(xs);i++)
- {
- for(int j = 0;j < L(ys);j++)
- {
- ll l = xs[i]-ys[j];
- lol.pb(l);
- }
- }
- sort(ALL(lol));
- lol.pb(LLINF);
- for(int i = 0;i < L(lol)-1;i++)
- {
- ll k = 0;
- while(lol[i]==lol[i+1])
- {
- i++;
- k++;
- }
- ans+=(1+k)*k/2;
- }
- cout << ans;
- }
Add Comment
Please, Sign In to add comment