Submission #433301

#TimeUsernameProblemLanguageResultExecution timeMemory
433301Tiago_MarquesFinding Routers (IOI20_routers)C++17
77 / 100
2 ms304 KiB
#include "routers.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

#define REP(i, a, b) for (ll i=a; i<b; i++)
#define pb push_back

std::vector<int> find_routers(int l, int n, int q)
{
    vector<int> ans(n);
    int minimo[n] = {};
    int maximo[n];
    REP(i, 0, n)
        maximo[i] = l;
    REP(i, 0, n)
    {
        while (minimo[i] < maximo[i])
        {
            int med = (minimo[i] + maximo[i] + 1)/2;
            int x = use_detector(med);
            for (int j=x; j>=0; j--)
            {
                if (maximo[j] <= med - 1)
                    break;
                maximo[j] = med - 1;
            }
            REP(j, x+1, n)
            {
                if (minimo[j] >= med)
                    break;
                minimo[j] = med;
            }
        }
    }
    ans[0] = 0;
    REP(i, 1, n)
        ans[i] = 2*minimo[i] - ans[i-1];
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...