Hrbust 2310 Tree Painting(欧拉路径性质)
来源:互联网 发布:20端口是什么 编辑:程序博客网 时间:2024/06/04 19:47
Tree PaintingTime Limit: 1000 MSMemory Limit: 131072 KTotal Submit: 42(22 users)Total Accepted: 19(16 users)Rating: Special Judge: NoDescriptionGive you a tree, can you draw the tree with minimum strokes without overlapping? Noted that it is ok if two strokes intersect at one point. Here we define a tree as a connected undirected graph with N points and N-1 edges.Input
The input data has several test cases. The first line contains a positive integer T (T<=20), indicates the number of test cases.
For each case:
The first line contains an integers N (2<=N<=10^5), indicates the number of points on the tree numbered from 1 to N.
Then follows N-1 lines, each line contains two integers Xi, Yi means an edge connected Xi and Yi (1<=Xi, Yi<=N).
OutputFor each test case, you should output one line with a number K means the minimum strokes to draw the tree.Sample Input2
2
1 2
5
1 2
1 5
2 3
2 4
Sample Output1
2
Source"尚学堂杯"哈尔滨理工大学第六届程序设计竞赛题意:给出一颗N个点N-1条边的树,问至少能有几笔画出来
欧拉路径性质:每有两个度数为级数的顶点就存在一条欧拉路径
#include <bits/stdc++.h>using namespace std;int t, n;int a[100000 + 10];int main(){ scanf("%d", &t); while(t--){ scanf("%d", &n); memset(a, 0, sizeof(a)); for(int i = 1; i < n; i++){ int x, y; scanf("%d%d", &x, &y); a[x]++, a[y]++; } int ans = 0; for(int i = 1; i <= n; i++){ if(a[i]&1) ans++; } printf("%d\n", ans>>1); }}
阅读全文
0 0
- Hrbust 2310 Tree Painting(欧拉路径性质)
- HRBUST 1351 欧拉路径及回路的判断~
- 欧拉函数性质
- 欧拉函数的性质
- 欧拉函数的性质
- 欧拉函数及其性质
- HDU2824【欧拉函数性质】
- 欧拉函数性质总结
- hdu 5728 (欧拉函数性质的应用)
- 欧拉函数的性质证明(欧拉筛)
- 欧拉函数 (一些性质和运用)内置杜教筛
- 欧拉回路(欧拉路径)
- 欧拉回路(欧拉路径)
- Hust oj 1351 欧拉路径(欧拉路径)
- TJU-3980Painting Tree(贪心)
- 欧拉函数及其部分性质
- 欧拉函数性质及介绍
- 欧拉函数以部分性质
- 源码编译安装Apache开机自启动
- Android源码编译步骤
- Java面试题
- poj1160 [IOI2000] Post Office(区间dp+四边形不等式)
- python中的内建属性
- Hrbust 2310 Tree Painting(欧拉路径性质)
- ReactNative之SideMenu
- P1083 [NOIP 2012]借教室
- Spring Boot 上传文件(spring boot upload file)
- hdu1166 敌兵布阵(线段树)
- 全排列生成算法:next_permutation
- test二进制文件是否由test.cpp生成的呢? 怎么判断?------还是strings
- Ubuntu+QT+Opencv环境搭建
- ReactNative支付宝支付问题