#include<bits/stdc++.h>
#include "infection.h"
using namespace std;
const int maxn = 1e5 + 5;
const int INF = 1e9 + 9;
void speed()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}


vector<int> solve(vector <pair<int, int>> r, vector<long long> d,
                  vector<int> s, vector<int> t, vector<bool> I)
{
    vector<int> ans(s.size(), 0);
    int n = 0;
    for(int i = 0; i < r.size(); i++)
    {
        n = max(max(r[i].first, r[i].second), n);
    }
    vector<vector<int>> v(n);
    bool ok = false;
    for(int i = 0; i < s.size(); i++)
    {
        if(I[i] == 1)
        {
            ok = true;
            ans[i] = (t[i] - s[i] + 1);
            for(int j = s[i]; j <= t[i]; j++)
            {
                v[j].push_back((j - s[i] + d[i]));
            }
        }
    }
    if(ok == false)
        return ans;
    for(int i = 0; i < s.size(); i++)
    {
        if(I[i] == 0)
        {
            bool z = 0;
            for(int j = s[i]; j <= t[i]; j++)
            {
                if(z == 1)
                    ans[i]++;
                else if(!v[j].empty())
                {
                    for(int x : v[j])
                    {
                        int cur = j - s[i] + d[i];
                        if(cur == x)
                        {
                            ans[i]++;
                            z = 1;
                        }
                    }
                }
            }
        }
    }
    return ans;
}


