# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
39503 | 14kg | Factories (JOI14_factories) | C++11 | 4099 ms | 144720 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 "factories.h"
#include <algorithm>
#include <vector>
#define N 500001
#define LL long long
#define INF 999999999999999999
#define min2(x,y) (x<y?x:y)
using namespace std;
int n, t[N], tree_up[N][20], p[20];
int tree_lev[N], tree_e[N];
LL deep[N];
vector<pair<int, int> > r[N];
int dfs_lev, q_len, dfs_num;
LL out;
pair<int, int> q[N * 3];
void dfs(int x, int up, LL _deep, int _t) {
tree_lev[x] = ++dfs_lev;
deep[dfs_lev] = _deep, t[dfs_lev] = _t;
tree_up[dfs_lev][0] = tree_lev[up];
for (int i = 1; i < 20; i++)
tree_up[dfs_lev][i] = tree_up[tree_up[dfs_lev][i - 1]][i - 1];
for (auto i : r[x])
if (i.first != up) dfs(i.first, x, _deep + (LL)i.second, _t + 1);
tree_e[tree_lev[x]] = dfs_lev;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |