水题一道,不是很懂为啥没人做。。。

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的更多相关文章

  1. BZOJ 4610: [Wf2016]Ceiling Functi 水题

    4610: [Wf2016]Ceiling Functi 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=4610 Description ...

  2. bzoj 4610 Ceiling Functi

    bzoj 4610 Ceiling Functi Description bzoj上的描述有问题 给出\(n\)个长度为\(k\)的数列,将每个数列构成一个二叉搜索树,问有多少颗形态不同的树. Inp ...

  3. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

  4. SQL Server 随机数,随机区间,随机抽取数据rand(),floor(),ceiling(),round(),newid()函数等

    在查询分析器中执行:select rand(),可以看到结果会是类似于这样的随机小数:0.36361513486289558,像这样的小数在实际应用中用得不多,一般要取随机数都会取随机整数.那就看下面 ...

  5. SQL中Round(),Floor(),Ceiling()函数的浅析

    项目中的一个功能模块上用到了标量值函数,函数中又有ceiling()函数的用法,自己找了一些资料,对SQL中这几个函数做一个简单的记录,方便自己学习.有不足之处欢迎拍砖补充 1.round()函数遵循 ...

  6. freemarker中的round、floor和ceiling数字的舍入处理

    freemarker中的round.floor和ceiling数字的舍入处理 1.简易说明 (1)round:四舍五入 (2)floor:向下取整 (3)ceiling:向上取整 2.举例说明 < ...

  7. SQL SERVER CEILING 函数 取整时的坑。。。

    CEILING ---返回大于或等于指定数值表达式的最小整数 当舍去同一个大小的值 但是正负方向不一致时要注意小数位四舍五入的问题   例如: SELECT CEILING($123.45), CEI ...

  8. freemarker中的round、floor和ceiling数字的舍入处理(十七)

    1.简易说明 (1)round:四舍五入 (2)floor:向下取整 (3)ceiling:向上取整 2.举例说明 <#--freemarker中的round.floor和ceiling数字的舍 ...

  9. 一:SqlServer中的 CEILING函数和 FLOOR函数以及ROUND()

    例如 1.ROUND() 格式为ROUND(y1,y2,y3) y1:要被四舍五入的数字y2:保留的小数位数 y3:为0,可以不写,y1进行四舍五入,不为0则y1不进入四舍五入,如果y1有值就直接根据 ...

随机推荐

  1. MySQL安装图解

    MySQL安装图解 打开下载的mysql安装文件mysql-5.0.27-win32.zip,双击解压缩,运行“setup.exe”,出现如下界面:           mysql安装向导启动,按“N ...

  2. Javascript setTimeout 带参数延迟执行 闭包实现

    不是原创,只是 借鉴别人的成果,我在此纪念 1.htm function GetDateT() { var d,s; d = new Date(); s = d.getFullYear() + &qu ...

  3. parted命令详解

    parted命令详解   用法:parted [选项]... [设备 [命令 [参数]...]...]   将带有“参数”的命令应用于“设备”.如果没有给出“命令”,则以交互模式运行.   帮助选项: ...

  4. nginx+php-fpm的socket配置小结

    关于socket的介绍本文不再赘述,生产环境中常用socket方式,本文简述其配置方式. #cd /app/local/php#切换到php安装目录下 #mkdir run #chmod 777 ./ ...

  5. curl 工具的使用

    curl命令是个功能强大的网络工具,支持通过http.ftp等方式下载文件.上传文件.还可以用来抓取网页.网络监控等方面的开发,解决开发过程中遇到的问题. 常用参数 curl命令参数很多,这里只列出我 ...

  6. Nginx:Pitfalls and Common Mistakes

    New and old users alike can run into a pitfall. Below we outline issues that we see frequently as we ...

  7. codeforces 719C (复杂模拟-四舍五入-贪心)

    题目链接:http://codeforces.com/problemset/problem/719/C 题目大意: 留坑...

  8. 获取<img src="sdf.jpg" Big="sf.jpg">中的big的值

    原代码: <img src="sdf.jpg" Big="sf.jpg" onclick="getsrc($(this).attr(" ...

  9. jquery.cookie使用方法

    jquery.cookie 使用方法 一个轻量级的 cookie 插件,可以读取.写入.删除 cookie . jquery.cookie.js 的配置 首先包含 jQuery 的库文件,在后面包含 ...

  10. Asp.NET的Trace追踪

    http://m.blog.csdn.net/article/details?id=7026402 当我们扑捉程序错误时,调试器是开发者们最得力的助手.然而,ASP.NET的跟踪,在调试时是一个很棒的 ...