Has Not Appeared
0/3
Parallel Binary Search
Author: Muaath Alqarni
Answering multiple binary search queries parallelly
Prerequisites
Resources
Resources | ||||
---|---|---|---|---|
CF |
Status | Source | Problem Name | Difficulty | Tags | |
---|---|---|---|---|---|
CSES | Easy | Show TagsDSU, PBS |
Solution - New Roads Queries
Let's think how to binary search a single query. It's clear that we can use DSU with linear search, but also we can do binary search with DSU in .
Now let's use parallel binary search: Sweep through the array, whenevery you find a query its median = , you will shrink it either to left or right. You need to do the sweep times, so every query is processed. Total Complexity:
Implementation - New Roads Queries
C++
#include <bits/stdc++.h>#define ll long long#define pii pair<int, int>using namespace std;const int N = 2e5 + 1;int n, m, q;vector<pii> edges;
Problems
Status | Source | Problem Name | Difficulty | Tags | |
---|---|---|---|---|---|
AC | Easy | Show TagsDSU, PBS | |||
COCI | Normal | Show TagsPBS, Segtree |
Module Progress:
Join the USACO Forum!
Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!