# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
594928 | czhang2718 | Dynamic Diameter (CEOI19_diameter) | C++17 | 226 ms | 37656 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;
typedef long long ll;
const int N=2e5+1;
int n, q, maxW;
vector<int> adj[N];
int edge[N][2];
int W[N];
int ti=-1;
int fst[N], lst[N];
vector<int> et;
ll path[N];
ll mx[4*N];
ll mn[4*N];
ll pref[4*N];
ll suf[4*N];
ll seg[4*N];
ll lazy[4*N];
void pull(int x){
mx[x]=max(mx[2*x+1], mx[2*x+2]);
mn[x]=min(mn[2*x+1], mn[2*x+2]);
pref[x]=max({pref[2*x+1], pref[2*x+2], mx[2*x+2]-2*mn[2*x+1]});
suf[x]=max({suf[2*x+1], suf[2*x+2], mx[2*x+1]-2*mn[2*x+2]});
// cout << "seg " << x << " = max " << seg[2*x+1] << ", " << seg[2*x+2] << ", " << pref[2*x+2] << "+" << mx[2*x+1] <<", " << mx[2*x+2] << "+" << suf[2*x+1] << "\n";
seg[x]=max({seg[2*x+1], seg[2*x+2], pref[2*x+2]+mx[2*x+1], mx[2*x+2]+suf[2*x+1]});
# | 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... |