# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1036522 | model_code | Petrol stations (CEOI24_stations) | C++17 | 3581 ms | 30876 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// 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;
}
컴파일 시 표준 에러 (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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |