# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
399258 | order999 | Synchronization (JOI13_synchronization) | C++14 | 283 ms | 22936 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.
/*
- Consider when we add an edge between nodes u and v that have a and b amounts of data, respectively, with c being the same
- Both components of u and v will now have a + b - c amounts of data
- c is just the amount of data shared between u and v the last time they were connected
- We now need to support the following queries:
- Add an edge
- Delete an edge
- Set values of all nodes in a connected component to x
- Find the value of a node
- Each connected component can be represented by the node that is closest to the root
- Let's color / erase these nodes when we add / delete edges
- Note that when we add an edge, one of its endpoints will become a representative
- A connected component's representative can be found with binary search and path sum queries (using binary indexed tree)
- For the set / find values queries, just process them on the representative
- O(nlog^2n) since it's O(log^2n) for finding a representative
*/
#include <bits/stdc++.h>
using namespace std;
const int mxN=1e5;
int n, m, q, x[mxN-1], y[mxN-1], st[mxN], en[mxN], dt, ft[mxN+1], v[mxN], lc[mxN-1], anc[mxN][17], dj, ck;
vector<int> adj[mxN];
inline void upd(int i, int x) {
for(++i; i<=n; i+=i&-i)
ft[i]+=x;
}
inline int qry(int i) {
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |