# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
235308 | ArshiaDadras | Zagrade (COI17_zagrade) | C++14 | 382 ms | 119548 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
map<int, int> mp1[N], mp2[N];
int n, cost1[N], cost2[N];
vector<int> adj[N];
long long ans;
void Swap(int u, int v) {
swap(mp1[u], mp1[v]);
swap(mp2[u], mp2[v]);
swap(cost1[u], cost1[v]);
swap(cost2[u], cost2[v]);
}
void dfs(int u, int par) {
int cost = cost1[u];
for (auto v: adj[u])
if (v ^ par) {
dfs(v, u);
bool rev = mp1[u].size() + mp2[u].size() < mp1[v].size() + mp2[v].size();
if (rev)
Swap(u, v);
for (auto [x, k]: mp1[v])
if (mp2[u].count(x + cost1[v] - cost2[u]))
ans += 1LL * k * mp2[u][x + cost1[v] - cost2[u]];
for (auto [x, k]: mp2[v])
if (mp1[u].count(x + cost2[v] - cost1[u]))
컴파일 시 표준 에러 (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... |