| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 861942 | sleepntsheep | Museum (CEOI17_museum) | C++17 | 328 ms | 785148 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 <cstdio>
#include <cstring>
#include <cassert>
#include <string>
#include <deque>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <iostream>
#include <utility>
using namespace std;
using ll = long long;
using ld = long double;
#define ShinLena cin.tie(nullptr)->sync_with_stdio(false)
#define N 10002
#define ALL(x) x.begin(), x.end()
int dp[N*2][N];
/*
* state: dp[u][i] = at u-th room, visited i room
*
* transition:
* dp[u][i] = min(dp[v1][i-1] + 2*w1, dp[v2][i-1] + 2*w2, min 1 <= k < i-1 (dp[v1][k] + dp[v2][i-1-k] + 2*w1 + 2*w2))
*/
int n, k, x;
vector<vector<pair<int, int>>> g;
vector<vector<pair<int, int>>> binarize(vector<vector<pair<int, int>>> g)
{
int nn = g.size();
vector<vector<pair<int, int>>> rg(nn);
for (int i = 0; i < g.size(); ++i)
{
if (g[i].size() > 2)
{
for (int j = 0, at = i; g[i].size() > j; ++j)
{
int new_node = nn++;
rg.resize(nn);
rg[at] = {g[i][j], {0, new_node}};
at = new_node;
}
}
else
rg[i] = g[i];
}
return rg;
}
ll dfs(int u, int p)
{
}
int main()
{
ShinLena;
cin >> n >> k >> x;
g.resize(n+1);
for (int i = 1, u, v, w; i < n; ++i)
cin >> u >> v >> w, g[u].emplace_back(w, v), g[v].emplace_back(w, u);
g = binarize(g);
memset(dp, -1, sizeof dp);
return 0;
}
Compilation message (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... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
