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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <bits/stdc++.h>

using namespace std;

#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define ll long long
int mod=1000000007;
int inf=1000000007;
ll infl=1000000000000000007;

ll a[25],r[25];
ll n;
set<ll>s;
vector<ll> act;
bool odw[25];
set<ll> s1;

void bum(ll x)
{
    s1.insert(x);
    for(ll i=1;i<=n;i++)
    {
        if(!s1.count(x)&&abs(a[i]-a[x])<=r[x]) bum(i);
    }
}

void bt(ll i)
{
    if(i==n+1)
    {
        ll res=0;
        s1.clear();
        for(auto x:act)
        {
            if(!s1.count(x))
            {
                bum(x);
            }
        }
        for(int i=1;i<=n;i++)
        {
            if(s1.count(i))
            {
                res|=(1<<(i-1));
            }
        }
        s.insert(res);
        return;
    }
    act.pb(i);
    bt(i+1);
    act.pop_back();
    bt(i+1);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(ll i=1;i<=n;i++) cin>>a[i]>>r[i];
    bt(1);
    cout<<sz(s);




    return 0;
}