이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include "routers.h"
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> find_routers(int l, int n, int q){
vector<int>ans(n);
ans[0]=0;
if (l%2!=0) l--;
vector<pair<int,int>>memoria(n, make_pair(0, 1e9));
for (int i=1; i<n; i++){
int right=min(l-2*(n-i-1), 2*memoria[i].second-ans[i-1]-2);
int left=max(ans[i-1]+2, 2*memoria[i-1].first-ans[i-1]);
int m;
bool tipo=false;
while (left!=right){
m=(right-left)/2+left;
if (m%2!=0) m++;
if (left+2==right){
int m3=(left-ans[i-1])/2+ans[i-1];
if (m3%2==0) m3+=2;
else m3++;
if (use_detector(m3)==i) right-=2;
else left+=2;
}
else if (tipo==false){
if (use_detector(m)==i+1){
memoria[i+1].second=min(memoria[i+1].second, m);
right=m-2;
}else{
memoria[i].first=max(memoria[i].first, m);
tipo=true;
}
}else{
int m2=(right-m)/2+m;
if (m2%2!=0) m2++;
if (use_detector(m2)==i+1){
memoria[i+1].second=min(memoria[i+1].second, m2);
right=m-2;
tipo=false;
}else memoria[i].first=max(memoria[i].first, m2);
}
}ans[i]=left;
}return ans;
}
# | 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... |