Submission #3188032
Source Code Expand
#include<iostream> #include<vector> using namespace std; #define rep(i,n) for(int i = 1; i <= n; i++) #define MAX_N 108 int n, x, h[MAX_N], a, b, used[MAX_N]; vector<int> G[MAX_N]; int dfs(int x, int cost){ int ans = 0; used[x] = true; if(h[x]) ans = cost*2, cost = 0; for(int y : G[x]){ if(used[y]) continue; ans += dfs(y,cost+1); } return ans; } int main(){ cin>>n>>x; rep(i,n) cin>>h[i]; rep(i,n-1){ cin>>a>>b; G[a].push_back(b),G[b].push_back(a); } cout<<dfs(x,0)<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - ツリーグラフ |
User | Okay |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 562 Byte |
Status | WA |
Exec Time | 1 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 100 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | subtask0_sample_01.txt, subtask0_sample_02.txt |
All | subtask0_sample_01.txt, subtask0_sample_02.txt, subtask1_line01.txt, subtask1_line02.txt, subtask1_line03.txt, subtask1_line04.txt, subtask1_line05.txt, subtask1_line06.txt, subtask1_random01.txt, subtask1_random02.txt, subtask1_random03.txt, subtask1_random04.txt, subtask1_random05.txt, subtask1_random06.txt, subtask1_random07.txt, subtask1_random08.txt, subtask1_special01.txt, subtask1_special02.txt, subtask1_special03.txt, subtask1_special04.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
subtask0_sample_01.txt | AC | 1 ms | 256 KB |
subtask0_sample_02.txt | AC | 1 ms | 256 KB |
subtask1_line01.txt | AC | 1 ms | 256 KB |
subtask1_line02.txt | AC | 1 ms | 256 KB |
subtask1_line03.txt | AC | 1 ms | 256 KB |
subtask1_line04.txt | AC | 1 ms | 256 KB |
subtask1_line05.txt | AC | 1 ms | 256 KB |
subtask1_line06.txt | AC | 1 ms | 256 KB |
subtask1_random01.txt | WA | 1 ms | 256 KB |
subtask1_random02.txt | WA | 1 ms | 256 KB |
subtask1_random03.txt | WA | 1 ms | 256 KB |
subtask1_random04.txt | WA | 1 ms | 256 KB |
subtask1_random05.txt | WA | 1 ms | 256 KB |
subtask1_random06.txt | WA | 1 ms | 256 KB |
subtask1_random07.txt | WA | 1 ms | 256 KB |
subtask1_random08.txt | WA | 1 ms | 256 KB |
subtask1_special01.txt | AC | 1 ms | 256 KB |
subtask1_special02.txt | AC | 1 ms | 256 KB |
subtask1_special03.txt | AC | 1 ms | 256 KB |
subtask1_special04.txt | AC | 1 ms | 256 KB |