uestc summer training #4 牛客第一场】的更多相关文章

A dp[i][j][k]可以n3地做 但是正解是找把问题转化为一个两点不相交路径 最终答案为C(n+m, n)2-C(n+m, m-1)C(n+m,n-1) B 把题目的矩阵看成无向图的邻接矩阵 这题可以转化为给你n个点 每个点的度数必须为2 有几种情况 Orz... C D 弄懂同构的意思然后直接暴力即可 E F G H I J 树状数组离线维护…
G.coloring tree BFS计数 题目:给你n(<=5000)个节点的一颗树 你有K(<=5000)种颜色 你可以给每一个节点染一种颜色 总共有Kn种染色方法 在一种染色方法中 定义colorness为每一对相同颜色节点距离中的最短距离 问colorness为D时 有多少种染色方案 结果%mod 解:我们先求出>=D的方案数再减去>=D+1的方案数就是==D的方案数 现在问题变为>=X的方案数 可以看成对于任意一个节点,所有和它距离小于d的节点,不能和它有相同的颜色…
链接:https://www.nowcoder.com/acm/contest/140/D 来源:牛客网 题目描述 White Cloud has built n stores numbered to n. White Rabbit wants to visit these stores to n. The store numbered i has a price a[i] representing that White Rabbit can spend a[i] dollars to buy…
链接:https://www.nowcoder.com/acm/contest/140/A 来源:牛客网 White Cloud is exercising in the playground. White Cloud can walk meters or run k meters per second. Since White Cloud is tired,it can't run for two or more continuous seconds. White Cloud will mov…
White Rabbit has a rectangular farmland of n*m. In each of the grid there is a kind of plant. The plant in the j-th column of the i-th row belongs the a[i][j]-th type.White Cloud wants to help White Rabbit fertilize plants, but the i-th plant can onl…
二维树状数组真的还挺神奇的,更新也很神奇,比如我要更新一个区域内的和,我们的更新操作是这样的 add(x1,y1,z); add(x2+1,y2+1,z); add(x1,y2+1,-z); add(x2+1,y1,-z); 我们会想为什么和一维的差这么多,我们不妨这样看 add(x1,y1,z);的更新效果 add(x2+1,y2+1,z);的更新效果 那么这个下半区有两个,我们再更新 add(x1,y2+1,-z);的更新效果 add(x2+1,y1,-z);的更新效果 最后用红的去剪掉黄色…
题目传送:https://www.nowcoder.com/acm/contest/140/C 题意:有n个云层,每个云层可以表示为y=ax+b.每个飞机的航线可以表示为时间x时,坐标为(x,cx+d).问飞机旅程与最后一个云层相交的x坐标.不存在 分析: 可以确定两直线联立后解得交点x=(b-d)/(a-c). 可以看做是点(a,b)和(c,d)的斜率的负数. 要求的最大的x,那么就变成了求得最小的斜率,答案最后再乘-1即可. 就是求每个(c,d)点到(a,b)的斜率,可以把每一个(a,b)看…
#include <cstdio> #include <iostream> #include <cstring> using namespace std; char str[10000008]; int main(){ char c ; int status = 0; strcpy(str,"0k"); int flag = 0; int s = 0; int len = 2; while((c = getchar())!= '\n'){ if((s…
题意: 给你n个点的权值和连边的信息,问你第k小团的值是多少. 思路: 用bitset存信息,暴力跑一下就行了,因为满足树形结构,所以bfs+优先队列就ok了,其中记录下最后进入的点(以免重复跑). #define IOS ios_base::sync_with_stdio(0); cin.tie(0); #include <cstdio>//sprintf islower isupper #include <cstdlib>//malloc exit strcat itoa sy…
思路: 概率结论题,好像属于线性递推,现在也不太懂(lll¬ω¬) #define IOS ios_base::sync_with_stdio(0); cin.tie(0); #include <cstdio>//sprintf islower isupper #include <cstdlib>//malloc exit strcat itoa system("cls") #include <iostream>//pair #include <…