| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1366446 | mariaclara | Petrol stations (CEOI24_stations) | C++20 | 3592 ms | 10248 KiB |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
vector<vector<pii>> edges;
vi sub, ans;
int k;
void dfs(int x, int pai, int fuel) {
sub[x] = 1;
for(auto [viz, d] : edges[x]) {
if(viz == pai) continue;
if(fuel < d) {
dfs(viz, x, k-d);
ans[x] += sub[viz];
} else dfs(viz, x, fuel-d);
sub[x] += sub[viz];
}
}
int main() {
int n;
cin >> n >> k;
edges.resize(n);
sub.resize(n);
ans.resize(n);
for(int i = 1, a, b, c; i < n; i++) {
cin >> a >> b >> c;
edges[a].pb({b, c});
edges[b].pb({a, c});
}
for(int i = 0; i < n; i++)
dfs(i, i, k);
for(int i = 0; i < n; i++)
cout << ans[i] << "\n";
}| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
