#include<bits/stdc++.h>
#include "infection.h"
using namespace std;
const int maxn = 512;
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);
    vector<pair<int, int>> Z(I.size());
    bool ok = false;
    for(int i = 0; i < s.size(); i++)
    {
        if(I[i] == 1)
        {
            ok = true;
            ans[i] = abs(t[i] - s[i] + 1);
            Z.push_back({i, 0});
        }
    }
    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
                {

                    for(auto x : Z)
                    {
                        if(abs(j - s[x.first]) == abs(j - s[i]) && abs(j - s[i]) >= x.second)
                        {
                            z = true;
                            //ans[i]++;
                            Z.push_back({i, abs(j - s[i])});
                        }
                    }
                }
            }
        }
    }
    return ans;
}

