ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#213593 | #573. t2 | yanruo_BGSSR_ypa | 0 | 0ms | 1260kb | C++11 | 545b | 2024-11-12 21:25:27 | 2024-11-12 23:52:19 |
answer
#include<bits/stdc++.h>
using namespace std;
int n,T,c[100001],la,d,ans;
struct edge{
int v,w,ne;
}e[200001];
void ae(int u,int v,int w){e[++la]={v,w,c[u]},c[u]=la;}
void dfs(int x,int s,int fa){
ans+=s;
for(int i=c[x];i;i=e[i].ne){
if(e[i].v==fa)continue;
dfs(e[i].v,(e[i].w%d?0:s+1),x);
}
}
signed main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>n>>T;
for(int i=1,u,v,w;i<n;i++)cin>>u>>v>>w,ae(u,v,w),ae(v,u,w);
while(T--){
cin>>d;
ans=0;
dfs(1,0,0);
cout<<ans<<'\n';
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 30
Accepted
time: 0ms
memory: 1260kb
input:
50 50 48 29 49788 47 48 31142 35 48 28665 10 35 23889 39 35 6411 50 39 66666 43 35 27629 46 10 49173...
output:
2 1 0 0 0 2 0 0 0 0 0 0 1 10 0 0 1 0 0 2 0 1 0 2 0 0 0 0 0 2 0 0 0 0 2 0 0 0 1 0 0 1 0 2 1 2 0 0 0 0
result:
ok 50 tokens
Test #2:
score: -30
Wrong Answer
time: 0ms
memory: 1256kb
input:
50 50 48 29 36145 47 29 82496 35 47 66171 10 47 40597 39 48 64355 50 48 98687 43 39 15472 46 35 3729...
output:
0 0 0 4 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 1 0 13 0 0 1 0 1 1 0 17 1 1 0 6 0 0 1
result:
wrong answer 32nd words differ - expected: '3', found: '2'
Subtask #2:
score: 0
Time Limit Exceeded
Test #11:
score: 0
Time Limit Exceeded
input:
100000 100000 73595 40695 76 13615 40695 96 65545 13615 84 19391 13615 76 2353 73595 27 26730 40695 ...
output:
result:
Subtask #3:
score: 0
Time Limit Exceeded
Test #21:
score: 0
Time Limit Exceeded
input:
100000 100000 73595 40695 12816 13615 73595 81821 65545 40695 75866 19391 65545 1165 2353 73595 3737...