File tree 1 file changed +10
-4
lines changed
1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -29,11 +29,15 @@ there are $\mathcal{O}(\sqrt N)$ updates or calculations. For each block:
29
29
- To achieve this, we simply use DSU with path balancing only and keep a
30
30
stack of previous DSU operations
31
31
32
- The complexity of this algorithm is thus $\mathcal{ O } ((Q + M) \sqrt Q)$. Some
33
- constant-factor optimization may be needed to get this to run in time though.
34
-
35
32
## Implementation
36
33
34
+ ** Time Complexity:** $\mathcal{ O } ((Q + M) \log N \sqrt Q )$
35
+
36
+ However, it is possible to remove the log factor as mentioned in [ this comment] ( https://codeforces.com/blog/entry/67129?#comment-514312 ) .
37
+
38
+ <LanguageSection >
39
+ <CPPSection >
40
+
37
41
``` cpp
38
42
#include < bits/stdc++.h>
39
43
#define FOR (i, x, y ) for (int i = x; i < y; i++)
@@ -130,6 +134,8 @@ int main() {
130
134
}
131
135
132
136
FOR (i , 1 , q + 1 ) if (t [i ] == 2 ) cout << ans [i ] << ' \n ' ;
133
- return 0 ;
134
137
}
135
138
` ` `
139
+
140
+ </CPPSection>
141
+ </LanguageSection>
You can’t perform that action at this time.
0 commit comments