# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
537645 | sliviu | Regions (IOI09_regions) | C++17 | 4762 ms | 101700 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0)->sync_with_stdio(0);
const int SQRT = 450;
int n, r, q, x, y, t = -1;
cin >> n >> r >> q;
vector<vector<int>> G(n + 1), regnodes(r + 1);
vector<int> tin(n + 1), tout(n + 1), reg(n + 1), nodes;
cin >> reg[1];
for (int i = 2; i <= n; ++i) {
cin >> x >> reg[i];
G[x].emplace_back(i);
G[i].emplace_back(x);
}
function<void(int, int)> dfs = [&](int node, int last) {
tin[node] = ++t;
regnodes[reg[node]].emplace_back(t);
nodes.emplace_back(node);
for (auto x : G[node])
if (x != last)
dfs(x, node);
tout[node] = t;
};
dfs(1, 0);
map<pair<int, int>, int> ans;
for (int i = 1; i <= r; ++i)
if (regnodes[i].size() >= SQRT) {
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |