제출 #1203340

#제출 시각아이디문제언어결과실행 시간메모리
1203340hazuFinding Routers (IOI20_routers)C++20
77.94 / 100
2 ms840 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);

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

            if(mid > 0 && mp[mid] > 0){
                detected = mp[mid];
            }else {
                detected = use_detector(mid);
                mp[mid] = detected;
            }

            if(detected == i-1){
                low = mid;
            }else {
                high = mid;
            }
        }
        ans.push_back(mid + mid - 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...