H:有趣的试剂(1317)
题目链接:http://acm.xidian.edu.cn/problem.php?id=1317
原题链接:http://codeforces.com/problemset/problem/902/B(看不懂题目的,可以去看原题,下面有样例说明)
核心就是他是一棵树,你总是要从上往下染;
1 #include<stdio.h> 2 3 int n,ans; 4 int father[10004]; 5 int clour[10004]; 6 int main() 7 { 8 int T; 9 scanf("%d",&T); 10 while(T--) 11 { 12 ans = 1; 13 scanf("%d",&n); 14 for(int i = 2;i <= n;i++) 15 scanf("%d",&father[i]); 16 17 for(int i = 1;i <= n;i++) 18 scanf("%d",&clour[i]); 19 20 for(int i = 2;i <= n;i++) 21 { 22 if(clour[i] != clour[father[i]]) 23 ans++; 24 } 25 printf("%d\n",ans); 26 } 27 return 0; 28 }
别人说明:https://blog.csdn.net/m0_37809890/article/details/78856185
相关推荐
山水沐光 2020-04-10
KilluaZoldyck 2020-02-27
徐建岗网络管理 2020-02-15
shangs00 2019-12-29
KilluaZoldyck 2019-12-19
Joymine 2019-11-09
喝咖啡的IT羊 2012-01-03
liangds 2012-06-03
小科的奋斗 2019-05-08
qingsongzdq 2019-06-20
nogi 2018-11-04
Drip 2018-09-23
lynjay 2018-09-05
Biao 2019-04-25
雨云轩 2010-01-22