# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
807103 | LIF | Finding Routers (IOI20_routers) | C++14 | 1 ms | 340 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "routers.h"
#include<bits/stdc++.h>
using namespace std;
int pos[300005];
int minn[300005];
bool check(int now,int find)
{
int idx = use_detector(now);
minn[idx] = min(minn[idx],now);
if(idx >= find)return true;
else return false;
}
std::vector<int> find_routers(int l, int n, int q) {
/*std::vector<int> ans;
for (int i = 0; i < n; i++) {
ans.push_back(0);
}*/
pos[0] = 0;
for(int i=1;i<n;i++)minn[i] = l;
for(int i=1;i<n;i++)
{
int ll = pos[i-1];
int rr = minn[i];
int ans;
while(ll <= rr)
{
int mid = (ll+rr)>>1;
if(check(mid,i) == true)
{
ans = mid;
rr = mid - 1;
}
else ll = mid + 1;
}
pos[i] = pos[i-1] + (ans - 1 - pos[i-1]) * 2;
}
vector<int> temp;
for(int i=0;i<n;i++)temp.push_back(pos[i]);
return temp;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |