BZOJ4610——[Wf2016]Ceiling Functi
水题一道,不是很懂为啥没人做。。。
1、题意:纠正一下。。bzoj的题意不是很对。。。注意不是堆,是不平衡的二叉树,就是非旋转的treap,
另外。。。插入的时候,小于插在左边。。大于等于插在右边
2、分析:大概是wf签到题吧。。维护size,暴力的递归比较时候相同。。。。
<pre name="code" class="cpp">#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define M 10000
inline int read(){
char ch = getchar(); int x = 0, f = 1;
while(ch < '0' || ch > '9'){
if(ch == '-') f = -1;
ch = getchar();
}
while('0' <= ch && ch <= '9'){
x = x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}
struct Node{
int size, x;
Node *ls, *rs;
} pos[M];
Node *root[M];
int tot;
int fa[M];
inline void insert(Node* &o, int x){
if(o == NULL){
o = &pos[++ tot];
o -> size = 1;
o -> x = x;
return;
}
o -> size ++;
if(x < o -> x) insert(o -> ls, x);
else insert(o -> rs, x);
}
inline int find(int x){
return fa[x] == x ? x : fa[x] = find(fa[x]);
}
inline bool diff(Node *x, Node *y){
if(x == NULL && y == NULL) return 0;
if(x == NULL) return 1;
if(y == NULL) return 1;
if(x -> size != y -> size) return 1;
return diff(x -> ls, y -> ls) | diff(x -> rs, y -> rs);
}
int main(){
int n = read(), K = read();
for(int i = 1; i <= n; i ++){
for(int j = 1; j <= K; j ++){
int x = read();
insert(root[i], x);
}
fa[i] = i;
}
for(int i = 1; i <= n; i ++){
for(int j = i + 1; j <= n; j ++){
if(!diff(root[i], root[j])){
int x = find(i), y = find(j);
if(x != y){
fa[x] = y;
}
}
}
}
int ans = 0;
for(int i = 1; i <= n; i ++) if(find(i) == i){
ans ++;
}
printf("%d\n", ans);
return 0;
}
BZOJ4610——[Wf2016]Ceiling Functi的更多相关文章
- BZOJ 4610: [Wf2016]Ceiling Functi 水题
4610: [Wf2016]Ceiling Functi 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=4610 Description ...
- bzoj 4610 Ceiling Functi
bzoj 4610 Ceiling Functi Description bzoj上的描述有问题 给出\(n\)个长度为\(k\)的数列,将每个数列构成一个二叉搜索树,问有多少颗形态不同的树. Inp ...
- bzoj AC倒序
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...
- SQL Server 随机数,随机区间,随机抽取数据rand(),floor(),ceiling(),round(),newid()函数等
在查询分析器中执行:select rand(),可以看到结果会是类似于这样的随机小数:0.36361513486289558,像这样的小数在实际应用中用得不多,一般要取随机数都会取随机整数.那就看下面 ...
- SQL中Round(),Floor(),Ceiling()函数的浅析
项目中的一个功能模块上用到了标量值函数,函数中又有ceiling()函数的用法,自己找了一些资料,对SQL中这几个函数做一个简单的记录,方便自己学习.有不足之处欢迎拍砖补充 1.round()函数遵循 ...
- freemarker中的round、floor和ceiling数字的舍入处理
freemarker中的round.floor和ceiling数字的舍入处理 1.简易说明 (1)round:四舍五入 (2)floor:向下取整 (3)ceiling:向上取整 2.举例说明 < ...
- SQL SERVER CEILING 函数 取整时的坑。。。
CEILING ---返回大于或等于指定数值表达式的最小整数 当舍去同一个大小的值 但是正负方向不一致时要注意小数位四舍五入的问题 例如: SELECT CEILING($123.45), CEI ...
- freemarker中的round、floor和ceiling数字的舍入处理(十七)
1.简易说明 (1)round:四舍五入 (2)floor:向下取整 (3)ceiling:向上取整 2.举例说明 <#--freemarker中的round.floor和ceiling数字的舍 ...
- 一:SqlServer中的 CEILING函数和 FLOOR函数以及ROUND()
例如 1.ROUND() 格式为ROUND(y1,y2,y3) y1:要被四舍五入的数字y2:保留的小数位数 y3:为0,可以不写,y1进行四舍五入,不为0则y1不进入四舍五入,如果y1有值就直接根据 ...
随机推荐
- ES6之模版字符串
ES6之模版字符串 最近在项目中使用了ES6的模版字符串,在这里加以总结. 1.之前我们也可以使用JavaScript输出模版字符串,通常是下面这样的: $("#result"). ...
- jQuery基础(2)-- jQuery 选择器
jQuery 选择器允许您对 HTML 元素组或单个元素进行操作.jQuery 选择器基于元素的 id.类.类型.属性.属性值等"查找"(或选择)HTML 元素. 它基于已经存在的 ...
- 从.o文件中提取指定开头依赖于外部接口的脚本
nm -g audio_la-audio.o | grep " U " | awk '{ print $2}' | grep "^gst_"
- Apache和Nginx配置支持苹果ATS方法
什么是ATS功能? ATS是iOS9和OS X El Capitan的一个新特性.开启该功能后,ATS对使用NSURLConnection, CFURL或NSURLSession 等APIs 进行的网 ...
- 最简单的jQuery插件
<script src="./jquery-1.7.1.min.js"></script><script>;(function($,undefi ...
- linux redhat6.4安装oracle11g
系统要求 1. Linux安装Oracle系统要求 系统要求 说明 内存 必须高于1G的物理内存 交换空间 一般为内存的2倍,例如:1G的内存可以设置swap 分区为3G大小 硬盘 5G以上 2.修 ...
- ArcGIS Server开发教程系列(8)ArcGIS API for Javascript-控件(小部件)(续)纯代码
完整代码如下: <html> <head> <meta http-equiv="Content-Type" content="text/ht ...
- CodeForces 701C They Are Everywhere (滑动窗口)
题目链接:http://codeforces.com/problemset/problem/701/C 题意:找到字符串中能包含所有元素的最短字符串长度. 利用“滑动窗口”解题 解题思路: 1. 遍历 ...
- php json_decode
php代码 <?php $data='[{"Name":"a1","Number":"123","Con ...
- YOURPHP的分页完整版
html代码 <?php print_r($ser['searchtype']);?> <select name="searchtype"> <opt ...