# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1152759 | xnqs | Bridges (APIO19_bridges) | C++20 | 3100 ms | 341068 KiB |
/*
* The main idea is to view the updates as time segments, more exactly an update has a start time and end time.
* We will solve the queries offline, sorting them in ascending order of weight. Depending on where in the timeline
* that query happened, we will work in one of the sqrt(N) DSUs that includes that timeline. This way, using DSU with
* rollback, we can solve each query in O(sqrt(N)*log(N)), because there are at most sqrt(N) updates in a sqrt block.
* Also, apparently the nodes are very small, so *maybe* we can try using uint16_t's to save some memory?
*
* Total time complexity: O(N*sqrt(N)*log(N))
* Total space complexity: O(N*sqrt(N))
*/
//#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
#include <numeric>
#include <unordered_map>
#include <cstdint>
const int BLK_SIZE = 727;
class DSURollback {
private:
struct DSUState {
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |