| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 1230100 | hitsuuj | Finding Routers (IOI20_routers) | C++20 | 0 ms | 0 KiB | 
#include "routers.h"
#include <iostream>
using namespace std;
std::vector<int> find_routers(int l, int n, int q) {
    std::vector<int> ans(1);
    if(n==2){
        int maks=l;
        int l=1,r=l;
        int med=0;
        while(l<=r){
            int mid=(l+r)/2;
            int x=use_detector(mid);
            if(x==1) r=mid-1;
            else{
                med=mid; 
                l=mid+1;
            }
        }
        ans.pb(med*2);
    }
    else{
        int las=0;
    for(int i=1;i<=l;i++){
        int cur=use_detector(i);
        // cout<<cur<<" ";
        if(las != cur){
            int mid=i-1;
            int dis=2*mid-ans.back();
            ans.push_back(dis);
        }
        las=cur;
    }
    }
    // cout<<endl;
    // for(int i=0;i<ans.size();i++) cout<<ans[i]<<" ";
	return ans;
}
// 1. mid*2 
// 2. 
// 0,1 known -> change pos+ last cp dis to the mid 
// 3. 
// -> finding the mid with binser 
// 4. 
// 0 4 6 8
// x       x   x   x
// 0 1 2 3 4 5 6 7 8 
// 1 1 1 2 2 2 3 3 4
// 0 4 8
// x       x       x
// 0 1 2 3 4 5 6 7 8 
// 1 1 1 2 2 2 2 4 4
// mid -> i
// mid+1 -> i+1
// mid (before change)
