# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
53631 | baactree | Regions (IOI09_regions) | C++17 | 7477 ms | 131072 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;
int n, r, q;
vector<int> adj[200005];
int arr[200005];
const int sz = 1000;
int cache[sz][25005];
pair<int,int> cnt[25005];
int inv[25005];
int le[200005], ri[200005];
vector<int> idx[25005];
vector<pair<int, int> > vec[25005];
int vn;
void dfs(int now, int par) {
idx[arr[now]].push_back(vn);
le[now] = vn++;
for (auto &there : adj[now]) {
if (there == par)continue;
dfs(there, now);
}
ri[now] = vn++;
vec[arr[now]].emplace_back(le[now], ri[now]);
}
int solve(int r1, int r2) {
int &ret = cache[inv[r1]][r2];
if (ret != -1) return ret;
ret = 0;
for (auto x : vec[r1]) {
int le = x.first;
int ri = x.second;
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |