1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <bits/stdc++.h>
using namespace std;
const int SIZE=1000000;
const int MOD=1000000007;
void imax(int &a, int b){
	a=max(a, b);
}
void imin(int &a, int b){
	a=min(a, b);
}
void lmax(long long &a, long long b){
	a=max(a, b);
}
void lmin(long long &a, long long b){
	a=min(a, b);
}
/*
	WARNING: I'm using strange bracket style!
*/
vector <pair <long long, long long> > v;
vector <int> graph[SIZE];
bool take[SIZE];
int q, x, y, res;
void rek(int k){
	if (k==v.size())
		{
		for (int i=0; i<v.size(); i++)
			if (take[i])
				for (auto v: graph[i])
					if (!take[v])
						return;
		res++;
		return;
		}
	take[k]=true, rek(k+1), take[k]=false, rek(k+1);
}
int main()
	{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>q;
	while (q--)
		cin>>x>>y, v.push_back({x, y});
	for (int i=0; i<v.size(); i++)
		for (int j=0; j<v.size(); j++)
			if (abs(v[i].first-v[j].first)<=v[i].second)
				graph[i].push_back(j);
	rek(0), cout<<res<<"\n";
	return 0;
	}