Submission #1203345

#TimeUsernameProblemLanguageResultExecution timeMemory
1203345hazuFinding Routers (IOI20_routers)C++20
100 / 100
1 ms584 KiB
#include "routers.h"
#include <unordered_map>
using namespace std;

std::vector<int> find_routers(int l, int n, int q) {

    int low,mid,high;
    std::vector<int> ans;
    unordered_map<int, int> mp;
    ans.push_back(0);
    mp[0] = 0;

    for(int i = 1; i < n; i++){
        low = 0;
        high = l;
        mid = (high+low)/2;
        while(low<high){
            int detected = 0;
            mid = (high+low)/2;
            //if(mid == low) break;

            if(mp.find(mid) != mp.end()){
                detected = mp[mid];
            }else {
                detected = use_detector(mid);
                mp[mid] = detected;
            }

            if(detected < i){
                low = mid+1;
            }else {
                high = mid;
            }
        }
        ans.push_back(((low-1) - ans.back()) * 2 + ans.back());
    }

	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...