# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
618865 | Zanite | Dynamic Diameter (CEOI19_diameter) | C++17 | 233 ms | 6944 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.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using Edge = pair<ll, pll>;
#define fi first
#define se second
const int maxN = 1e5 + 5;
ll n, q, w;
ll id[maxN], dist[maxN];
multiset<ll> dpq;
int main() {
scanf("%lld %lld %lld", &n, &q, &w);
dpq.insert(0);
for (ll a, b, c, i = 1; i < n; i++) {
scanf("%lld %lld %lld", &a, &b, &c);
if (b == 1) swap(a, b);
id[i-1] = b;
dist[b] = c;
dpq.insert(c);
}
ll last = 0;
for (ll d, e, i = 1; i <= q; i++) {
scanf("%lld %lld", &d, &e);
d = (d + last) % (n - 1);
e = (e + last) % w;
ll change = id[d];
dpq.erase(dpq.lower_bound(dist[change]));
dist[change] = e;
dpq.insert(e);
auto it = dpq.begin();
last = *it;
it++;
last += *it;
printf("%lld\n", last);
}
}
Compilation message (stderr)
# | 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... |