F - How Many Tables 并查集的模板都能直接套,太简单不注释了,就存个代码 #include<bits/stdc++.h> using namespace std; ; int parent[size]; ]; int t, n, m, x, y, num; //赋初值 void parentkey(int n){ ;i<=n;i++){ parent[i] = i; cnt[i] = ; } } //找根节点 int find(int x){ return x==par…
How Many Tables Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 31632 Accepted Submission(s): 15706 Problem Description Today is Ignatius' birthday. He invites a lot of friends. Now it's dinner ti…
B. Mr. Kitayuta's Colorful Graph -> Link <- 题目链接在上面,题目比较长,就不贴出来了,不过这是道很好的题,很多方法都可以做,真心邀请去A了这道题: 题意:n个顶点m条边的无向图,每输入的两个点之间可能有多种颜色连接在一起,然后查询时每输入两个点,问这两个点之间有多少条连接方式: 如图: 1代表红色,2代表蓝色,3代表绿色: 这样3和4之间就是用绿色连接在一起的,他们之间只有一种连接方式,而2和3之间就有两种连接方式了,1和3只有一种(…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1213 Problem Description Today is Ignatius' birthday. He invites a lot of friends. Now it's dinner time. Ignatius wants to know how many tables he needs at least. You have to notice that not all the fri…
How Many Tables Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 14081 Accepted Submission(s): 6912 Problem Description Today is Ignatius' birthday. He invites a lot of friends. Now it's dinn…