# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1045792 | 2024-08-06T07:44:56 Z | CyberCow | Petrol stations (CEOI24_stations) | C++17 | 0 ms | 348 KB |
#include <random> #include <algorithm> #include <bitset> #include <chrono> #include <cmath> #include <deque> #include <fstream> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> #include <chrono> #define m_p make_pair #define all(x) (x).begin(),(x).end() #define sz(x) ((x).size()) typedef long long ll; using ull = unsigned long long; using namespace std; mt19937 rnd(348502); ll mod1 = 998244353; ll mod = 1e9 + 7; const ll N = 1005; vector<pair<int, int>> v[N]; int ans[N], k; void Dfs(int g, int p, int arj) { for (auto to : v[g]) { if (to.first != p) { if (to.second > arj) { ans[g]++; Dfs(to.first, g, k); } else { Dfs(to.first, g, arj - to.second); } } } } void solve() { int n, i, j, m, x, y, l; cin >> n >> k; if (n <= 1000) { for (i = 0; i < n - 1; i++) { cin >> x >> y >> l; v[x].push_back({ y, l }); v[y].push_back({ x, l }); } for ( i = 0; i < n; i++) { Dfs(i, -1, k); } for ( i = 0; i < n; i++) { cout << ans[i] << '\n'; } } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); ll tt = 1; //cin >> tt; while (tt--) { solve(); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |