CodeForces Segment Trees, Part 2, 4.4
Problem statement.
https://codeforces.com/edu/course/2/lesson/5/4/practice/contest/280801/problem/D
This segment tree will support two operations:
- Add value d to segment [r, l) .
- For segment [r, l) find weighted sum: A[r]*1 + A[r+1]*2 + ...
We will keep in T two values (sum, weighted sum) . We will keep in L one value lazy update: d , now what we need to understand is how to propagate updates.
Standart compexities for segment tree.
we can use Segment problems 2.4 and 4.2 and combine them.
Instructors: Yihan Sun and Yan Gu
Winter 2023
Assignments & Projects
Please carefully read the Academic Integrity before you start working on the homework assignments.
In short, you can get help from the instructors, TAs, textbooks (or relevant books), the Internet, or discussions with your classmates, but you must cite them fully and completely (i.e., provide citations to the book or website link, acknowledge the other students that had discussions with you). Again, you are NOT allowed to :
- copy anything from the book or the Internet,
- read or look at anyone else’s solutions (write-up or code),
- share your solutions (write-up or code) with any other students, during or after the completion of the course.
When you write down your solution, it MUST be close-book . This is to make sure you truly understand and can recreate the solutions.
📃 Course Policy Test
We have a course policy test about academic integrity and course policy. It takes 1/100 point in your overall grade. This test is due on 01/12.
📃 Entrance Exam
There is an entrance exam for this course. There are 4 programming problems, covering several important algorithms you should have learned in prerequisite courses (simple programming, simple sorting, graph algorithms, and some algorithm design ideas). You need to finish them in the first week. They will take 9/100 points in your overall grade. The four problems will be 11 points in total, and the full mark is 9 points. If you get more than 9 points, they will count as bonus points. Ideally you should pass all the 4 problems. ⚠ We would not recommend anyone getting <= 6 points to take the course.
If you cannot finish them in the first week, then CS 142 can be very challenging for you. You should consider taking prerequi courses for algorithms and programming, including CS 10A/B/C, 11, 111 and 141.
Problem-Solving Assignments
All problems will be given on codeforces (including the entrance exam), so we do not post the problems here.
We will use CodeForces to submit and test codes. You also need to submit a short report to describe your algorithm and specify your submission id. Here is a guideline about using CodeForces. Here is a beginner’s cheatsheet for learning programming.
We run automatic code comparison programs on student solutions. These programs are very good at detecting similarity between code, even code that has been purposefully obfuscated. Such programs can compare a submitted assignment against all other submitted assignments, against all known previous solutions of a problem, etc. The signal-to-noise ratio of such comparisons is usually very distinctive, making it very clear what code is a student’s original creative work and what code is merely transcribed from some other source. Cheating is simply not worth the risk.
You need to submit a brief report on how you solved these problems, including:
- Your name, SID and/or NETID, and your codeforces ID;
- Submission ID (there is a unique id for each submission);
- Describe the algorithm you designed;
- Show cost analysis if necessary.
You will not get the point if you don’t provide the report to explain how your algorithm works.
Each programming assignment takes 10/100 points in your overall grade. In each assignment, there are six problems. The first three problems are basic problems, and are easier. Each of them is worth for 3 points. The last three problems are challenge problems and are haeder. Each of them is 1 point.
You can get 12 points at maximum for each assignment. If you get more than 10 points in one assignment, they will be counted as bonus bonus. Note that you need to finish at least 1 challenge problem to get full points.
For challenge programming assignments, you can work on them after the deadline - as long as you finish them before the end of the class, you can still get half of the credits.
Performance-Engineering Assignments
Performance-Engineering Assignments are mini projects that requires programming. Generally, your goal is to write parallel code to engineer a specific problem. You will test and run your code on a server at UCR, and the detailed instruction will be given in the assignment problem description.
Each performance-engineering assignment contributes 15/100 to your overall grade. Similar to the problem-solving training, you can get more than 15 points if you get the bonus points.
Written Assignments
There are two written assignmetns. Each takes 5/100 points in your overall grade. The written part is similar to other algorithm courses you have taken, and you must use LaTeX to prepare your solution. Here you can find sample code for writing solutions using LaTeX.
In grading, we will reward not only correctness but also clarity and simplicity . To avoid losing points for hard-to-understand solutions, you should make sure your solutions are either self-explanatory or contains good explanations. Please understand that grading your assignments is a lot of work for your TAs and readers, especially determining the correctness and cost bounds for your algorithms. We reserve the right to manually deduct points for solutions that are conceptually correct but does not show a sincere attempt to explain the ideas clearly.
Presentation
At the end of the class, you can choose to give a presentation in class to get bonus points. We encourage you to present one of your favorite bonus questions and your solution to the class. For bonus question presentation, you have to pass all the test cases before the presentation.
AMA: TheOneYouWant
Atcoder ABC #351 Short Solution Discussion
- Submissions
- Problemsetting
edufgf's blog
Multiple Assignment Problem
Hello Codeforces community,
I have come across this problem and I would like some help.
You are given N machines and M jobs. Each machine has a processing power P_i (integer). Each job requests a processing power P_j (integer). A job j is complete when it has a total of P_j power coming from 1 or more machines. A machine can provide some part of it's power to one or more jobs.
The bold parts above are what makes it different than the standard assignment problem.
It's guaranteed that sum of machine power = sum of job request power. Which means all jobs can be completed.
I want to minimize the number of assignments (machine, job).
Machine A (50) Machine B (30) Machine C (40)
Job A (70) Job B (50)
Minimum assignments: 3 (machine A sends 50 to job B) (machine B sends 30 to job A) (machine C sends 40 to job A)
Is there any algorithm that solves this? (excluding brute force)
It sounds like the Generalized assignment problem, but with less restrictions. https://en.wikipedia.org/wiki/Generalized_assignment_problem
This is a bipartide graph, with integer flows and balanced.
The closest solution I got is (aside from brute force) to try a mincost-maxflow algorithm setting the imbalances and enforcing a fixed cost (say 1) to use one edge (independent of the amount of flow). However I am not sure if that works, because there is also the dual problem using potential and reduced costs. I don't know how to handle that on this problem.
- Custom test
Navigation Menu
Search code, repositories, users, issues, pull requests..., provide feedback.
We read every piece of feedback, and take your input very seriously.
Saved searches
Use saved searches to filter your results more quickly.
To see all available qualifiers, see our documentation .
- Notifications
IMAGES
VIDEO
COMMENTS
There was a problem that used the idea of Hungarian algorithm and not the algorithm itself in a Bulgarian competition, so I thought it'd be nice to know how it works even if I don't use it only for the assignment problem. Xellos. Ford-Fulkerson is really the simplest one. Cycle-Cancelling, Successive shortest path and Primal-Dual.
Solution. This segment tree will support two operations: Add value d to segment [r, l). For segment [r, l) find weighted sum: A[r]*1 + A[r+1]*2 + ... We will keep in T two values (sum, weighted sum). We will keep in L one value lazy update: d, now what we need to understand is how to propagate updates.
Collection of my Codeforces problems as well as popular algorithms with easy to understand solutions and comments about ideas in problems - Ramez-/Codeforces-solutions-explained
Codeforces. Programming competitions and contests, programming community. The only programming contests Web 2.0 platform
All problems will be given on codeforces (including the entrance exam), so we do not post the problems here. ... You will test and run your code on a server at UCR, and the detailed instruction will be given in the assignment problem description. Each performance-engineering assignment contributes 15/100 to your overall grade. Similar to the ...
For each test case, output a single integer −1 − 1 if a suitable division does not exist. Otherwise, on the first line, output an integer k k ( 2 ≤ k ≤ n 2 ≤ k ≤ n) — the number of subsegments in the division. Then output k k lines — the division into subsegments. The i i -th line should contain two integers li l i and ri r i ...
pashka → Editorial for Codeforces Round 920 (Div. 3) jackylova_fan_fan_fan → About problem F last night . tolbi → Two Factor Authentication When Changing E-mail . rutvik_1234 → Invitation to Epiphany, organized by ACM NIT Surat . pashka ...
To associate your repository with the codeforces-edu topic, visit your repo's landing page and select "manage topics." GitHub is where people build software. More than 100 million people use GitHub to discover, fork, and contribute to over 420 million projects.
Codeforces Round 629 (Div. 3) Finished: ... If you've seen these problems, a virtual contest is not for you - solve these problems in the archive. If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive. Never use someone else's code, read the tutorials or communicate with ...
Codeforces. Programming competitions and contests, programming community. → Pay attention
Before contest Codeforces Round 941 (Div. 1) 4 days. Before contest Codeforces Round 941 (Div. 2) 4 days. → Filter Problems Difficulty: — Add tag ...
Saved searches Use saved searches to filter your results more quickly
Codeforces Round 901 (Div. 1) Finished: ... If you've seen these problems, a virtual contest is not for you - solve these problems in the archive. If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive. Never use someone else's code, read the tutorials or communicate with ...
Educational Codeforces Round 92 (Rated for Div. 2) Finished: ... If you've seen these problems, a virtual contest is not for you - solve these problems in the archive. If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive. Never use someone else's code, read the tutorials or ...
Codeforces Round 498 (Div. 3) Finished: ... If you've seen these problems, a virtual contest is not for you - solve these problems in the archive. If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive. Never use someone else's code, read the tutorials or communicate with ...
The package for this problem was not updated by the problem writer or Codeforces administration after we've upgraded the judging servers. To adjust the time limit constraint, a solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then the value 800 ms will be displayed and used to ...
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window.
Saved searches Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window.