-
Notifications
You must be signed in to change notification settings - Fork 488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Parallel Binary Search module #3859
Closed
Closed
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
b5dc7b6
Adding Parallel Binary Search
Muaath5 ff5d8d3
Create Parallel_Binary_Search.problems.mdx
Muaath5 37b4b79
Create Parallel_Binary_Search.mdx
Muaath5 a04b44b
Fixing parallel binary search
Muaath5 b10a73c
Fixes, Testing
Muaath5 6f44eee
Improving code
Muaath5 b234af3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 7253394
Fixing typo
Muaath5 bb5f3c7
Merge branch 'master' of https://github.com/Muaath5/usaco-guide
Muaath5 b1c0bba
Merge branch 'master' into master
Muaath5 38b7c1c
Improving explaination, adding a problem
Muaath5 f59eb78
Merge branch 'master' of https://github.com/Muaath5/usaco-guide
Muaath5 ede0d51
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 8a49998
Improvements
Muaath5 71074f9
Merging
Muaath5 76d6939
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] b8b7e7c
Adding D&Q Tag to PBS
Muaath5 1f8030e
Merge branch 'master' of https://github.com/Muaath5/usaco-guide
Muaath5 ad2164f
Editing description
Muaath5 5818b96
Fixing typos
Muaath5 86ab2d9
Removing temp files
Muaath5 a9c94b0
Editing description
Muaath5 ced91e8
Fixing prerequisites, Adding tutoial
Muaath5 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fixing typos
- Loading branch information
commit 5818b96ab48d7f067a043c354036cd84fbb1f3c0
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,15 +20,14 @@ frequency: 0 | |
<FocusProblem problem="sam" /> | ||
|
||
## Solution - New Roads Queries | ||
Let's think about how to use binary to answer single query. | ||
We can see that connvectivity of the nodes is a monotonic function. | ||
We can see that connectivity of the nodes is a monotonic function. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How |
||
|
||
Now let's use parallel binary search: | ||
|
||
First, sort the queries by median. | ||
|
||
Then sweep through the array of edges and union them in the DSU, | ||
whenevery there is a query with median = $i$, if the two nodes where connected in DSU, it means the answer is $\leq i$, otherwise it means $\gt i$. | ||
Then sweep through the array of edges and union them in the DSU. | ||
Whenever there is a query with median = $i$, if the two nodes where connected in DSU, it means the answer is $\leq i$, otherwise it means $\gt i$. | ||
|
||
**Complexity:** | ||
|
||
|
55 changes: 55 additions & 0 deletions
55
content/6_Advanced/Parallel_Binary_Search.problems.json.save
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"MODULE_ID": "parallel-binary-search", | ||
"sam": [ | ||
{ | ||
"uniqueId": "cses-2101", | ||
"name": "New Roads Queries", | ||
"url": "https://cses.fi/problemset/task/2101/", | ||
"source": "CSES", | ||
"difficulty": "Easy", | ||
"isStarred": false, | ||
"tags": ["PBS", "DSU"], | ||
"solutionMetadata": { | ||
"kind": "internal" | ||
} | ||
} | ||
], | ||
"gen": [ | ||
{ | ||
"uniqueId": "hr-travelInHackerland", | ||
"name": "Travel in Hackerland", | ||
"url": "https://www.hackerrank.com/contests/may-world-codesprint/challenges/travel-in-hackerland", | ||
"source": "HR", | ||
"difficulty": "Easy", | ||
"isStarred": true, | ||
"tags": ["PBS", "DSU"], | ||
"solutionMetadata": { | ||
} | ||
}, | ||
{ | ||
"uniqueId": "ac-stampRally", | ||
"name": "Stamp Rally", | ||
"url": "https://atcoder.jp/contests/agc002/tasks/agc002_d", | ||
"source": "AC", | ||
"difficulty": "Easy", | ||
"isStarred": false, | ||
"tags": ["PBS", "DSU"], | ||
"solutionMetadata": { | ||
"kind": "autogen-label-from-site", | ||
"site": "AC" | ||
} | ||
}, | ||
{ | ||
"uniqueId": "coci-20-index", | ||
"name": "2020 - Index", | ||
"url": "https://evaluator.hsin.hr/tasks/HONI202167index/", | ||
"source": "COCI", | ||
"difficulty": "Normal", | ||
"isStarred": false, | ||
"tags": ["PBS", "Segtree"], | ||
"solutionMetadata": { | ||
"kind": "none" | ||
} | ||
} | ||
] | ||
} |
68 changes: 68 additions & 0 deletions
68
content/6_Advanced/Parallel_Binary_Search.problems.json.save.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
{ | ||
"MODULE_ID": "parallel-binary-search", | ||
"sam": [ | ||
{ | ||
"uniqueId": "cses-2101", | ||
"name": "New Roads Queries", | ||
"url": "https://cses.fi/problemset/task/2101/", | ||
"source": "CSES", | ||
"difficulty": "Easy", | ||
"isStarred": false, | ||
"tags": ["PBS", "DSU"], | ||
"solutionMetadata": { | ||
"kind": "in-module", | ||
"moduleId": "parallel-binary-search" | ||
} | ||
} | ||
], | ||
"gen": [ | ||
{ | ||
"uniqueId": "ac-IndependentSet", | ||
"name": "Independent Set", | ||
"url": "{ | ||
"uniqueId": "ac-IndependentSet", | ||
"name": "Independent Set", | ||
"url": "https://atcoder.jp/contests/dp/tasks/dp_p", | ||
"source": "AC", | ||
"difficulty": "Easy", | ||
"isStarred": true, | ||
"tags": ["Tree", "DP"], | ||
"solutionMetadata": { | ||
"kind": "internal" | ||
} | ||
}", | ||
"source": "AC", | ||
"difficulty": "Easy", | ||
"isStarred": true, | ||
"tags": ["PBS", "DSU"], | ||
"solutionMetadata": { | ||
"kind": "none" | ||
} | ||
}, | ||
{ | ||
"uniqueId": "ac-stampRally", | ||
"name": "Stamp Rally", | ||
"url": "https://atcoder.jp/contests/agc002/tasks/agc002_d", | ||
"source": "AC", | ||
"difficulty": "Easy", | ||
"isStarred": false, | ||
"tags": ["PBS", "DSU"], | ||
"solutionMetadata": { | ||
"kind": "autogen-label-from-site", | ||
"site": "AC" | ||
} | ||
}, | ||
{ | ||
"uniqueId": "coci-20-index", | ||
"name": "2020 - Index", | ||
"url": "https://evaluator.hsin.hr/tasks/HONI202167index/", | ||
"source": "COCI", | ||
"difficulty": "Normal", | ||
"isStarred": false, | ||
"tags": ["PBS", "Segtree"], | ||
"solutionMetadata": { | ||
"kind": "none" | ||
} | ||
} | ||
] | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely expand on this solution