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
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

pair<long long, long long> p[300001];
long long x[300001];
pair<int, int> z[300001];

vector<int> E[300001];

int vis[300001];

void dfs(int u, int k)
{
  vis[u] = k;
  
  for (int i = 0; i < E[u].size(); i++)
  {
    int v = E[u][i];
    if (!vis[v])
    {
      dfs(v, k);
    }
  }
}

int main()
{
  int n;
  scanf("%d", &n);
  
  for (int i = 0; i < n; i++)
  {
    long long a, r;
    scanf("%lld %lld", &a, &r);
    
    p[i].first = a - r; 
    p[i].second = a + r;
    x[i] = a;
  }
  
  
  for (int i = 0; i < n; i++)
  {
    int r = -1;
    int l = n;
    for (int j = 0; j < n; j++)
    {
      if (p[i].first <= x[j] && x[j] <= p[i].second)
      {
        l = min(l, j);
        r = max(r, j);
      }
    }
    z[i] = {l, r};
  }
  

  for (int i = 0; i < n; i++)
  {
    int r = -1;
    int l = n;
    for (int j = i + 1; j < n; j++)
    {
      int l0 = z[i].first;
      int r0 = z[i].second;
      int l1 = z[j].first;
      int r1 = z[j].second;
      
      if (l0 <= j && j <= r0)
      {
        E[i].push_back(j);
      }
      if (l1 <= i && i <= r1)
      {
        E[j].push_back(i);        
      }
    }
  }
  
  set<int> S;
  for (int i = 0; i < (1 << n); i++)
  {
    memset(vis, 0, n * 4);
    for (int j = 0; j < n; j++)
    {
      if ((1 << j) & i)
      {
        if (!vis[j])
          dfs(j, 1);
      }
    }
    int mask = 0;
    for (int j = 0; j < n; j++)
    {
      if (vis[j])
      {
        mask |= 1 << j;
      }
    }
    S.insert(mask);
  }
  

  printf("%d", S.size());
  return 0;
}