# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1036522 | 2024-07-27T13:31:04 Z | model_code | Petrol stations (CEOI24_stations) | C++17 | 3500 ms | 30876 KB |
// Author: Jiří Kalvoda #include<bits/stdc++.h> using namespace std; using ll = long long; int n; ll k; struct Node{ vector<pair<Node*, ll>> e; ll counts=0; int id; int go(ll current_power, Node *from) { int subtree_size = 1; for(auto &[nd, l] : e) if(nd != from) { ll r_power = current_power - l; if(r_power < 0) { int r_subtree_size = nd->go(k-l, this); counts += r_subtree_size; subtree_size += r_subtree_size; } else subtree_size += nd->go(r_power, this); } return subtree_size; } } *nds; int main(int argc, char ** argv) { scanf("%d%lld", &n, &k); nds = new Node[n]; for (int i=0; i<n; i++) nds[i].id = i; for (int i=0; i<n-1; i++) { int a,b; ll l; scanf("%d%d%lld", &a, &b, &l); nds[a].e.push_back({nds+b, l}); nds[b].e.push_back({nds+a, l}); } for (int i=0; i<n; i++) nds[i].go(k, NULL); for (int i=0; i<n; i++) printf("%lld\n", nds[i].counts); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 5 ms | 344 KB | Output is correct |
4 | Correct | 9 ms | 348 KB | Output is correct |
5 | Correct | 8 ms | 348 KB | Output is correct |
6 | Correct | 12 ms | 604 KB | Output is correct |
7 | Correct | 10 ms | 568 KB | Output is correct |
8 | Correct | 0 ms | 344 KB | Output is correct |
9 | Correct | 8 ms | 348 KB | Output is correct |
10 | Correct | 10 ms | 528 KB | Output is correct |
11 | Correct | 7 ms | 520 KB | Output is correct |
12 | Correct | 7 ms | 348 KB | Output is correct |
13 | Correct | 8 ms | 524 KB | Output is correct |
14 | Correct | 7 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Execution timed out | 3581 ms | 30876 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Execution timed out | 3581 ms | 30876 KB | Time limit exceeded |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Execution timed out | 3557 ms | 6748 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Execution timed out | 3557 ms | 6748 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 5 ms | 344 KB | Output is correct |
4 | Correct | 9 ms | 348 KB | Output is correct |
5 | Correct | 8 ms | 348 KB | Output is correct |
6 | Correct | 12 ms | 604 KB | Output is correct |
7 | Correct | 10 ms | 568 KB | Output is correct |
8 | Correct | 0 ms | 344 KB | Output is correct |
9 | Correct | 8 ms | 348 KB | Output is correct |
10 | Correct | 10 ms | 528 KB | Output is correct |
11 | Correct | 7 ms | 520 KB | Output is correct |
12 | Correct | 7 ms | 348 KB | Output is correct |
13 | Correct | 8 ms | 524 KB | Output is correct |
14 | Correct | 7 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 344 KB | Output is correct |
16 | Execution timed out | 3581 ms | 30876 KB | Time limit exceeded |
17 | Halted | 0 ms | 0 KB | - |