# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
933501 |
2024-02-25T19:00:18 Z |
Juanchoki |
Race (IOI11_race) |
C++14 |
|
4 ms |
18268 KB |
#include <bits/stdc++.h>
#include <vector>
#include "race.h"
using namespace std;
int mini = 1e9;
const int maxn = 2e5 + 13;
struct edge
{
int u, w;
};
vector<edge> adj[maxn];
struct par
{
int dist, arista;
};
bool operator < (const par &a, const par &b)
{
return a.dist < b.dist;
}
map<int, int> mp[maxn];
int k;
void dfs(int nodo, int padre)
{
for (edge e: adj[nodo])
{
if (e.u == padre) continue;
dfs(e.u, nodo);
if (mp[e.u].size() <= mp[nodo].size())
swap(mp[e.u], mp[nodo]);
for (auto it: mp[e.u])
{
int yo = it.first;
if (mp[nodo].count(k-yo))
mini = min (mini, mp[nodo][k-yo] + it.second);
int nuevo = it.first + e.w;
int aristas = it.second+1;
if (mp[nodo].count(nuevo))
if (mp[nodo][nuevo] < aristas)
mp[nodo][nuevo] = aristas;
else
{}
else
mp[nodo][nuevo] = aristas;
}
}
}
int best_path(int N, int K, int H[][2], int L[])
{
k = K;
for (int i = 0; i < N-1; i++)
{
adj[H[i][0]].push_back({H[i][1], L[i]});
adj[H[i][1]].push_back({H[i][0], L[i]});
}
for (int i = 0; i < N; i++)
mp[i].insert({0, 0});
dfs(0, -1);
return mini;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
18268 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
18268 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
18268 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
18268 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |