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有值就直接根据 ...
随机推荐
- beautifulsoup测试
import re from bs4 import BeautifulSoup html_doc = """ <html><head><ti ...
- Java排序算法——选择排序
import java.util.Arrays; //================================================= // File Name : Select_S ...
- codeforces 723B Text Document Analysis(字符串模拟,)
题目链接:http://codeforces.com/problemset/problem/723/B 题目大意: 输入n,给出n个字符的字符串,字符串由 英文字母(大小写都包括). 下划线'_' . ...
- hdu 5878 I Count Two Three (2016 ACM/ICPC Asia Regional Qingdao Online 1001)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5878 题目大意: 给出一个数n ,求一个数X, X>=n. X 满足一个条件 X= 2^a*3^ ...
- PHP----Ajax异步请求
需要两个PHP页面:1.php是发出请求和接受请求结果的.2.php是处理请求的结果. 1.php中代码: <a href="#" onclick="sendAja ...
- Redis学习——环境搭建以及基础命令使用
0. 前言: 这篇文章旨在对redis环境的搭建以及对redis有个大概的认识. 一.redis搭建: 环境:ubuntu 14 软件包:redis-3.0.3.tar.gz 安装步骤: 1. 首先解 ...
- Using Friendly URLs in ASP.NET Web Forms
Introduction Websites often need to generate SEO friendly URLs. In ASP.NET Web Forms applications, a ...
- Unity中各个平台的预编译的运用方式
1,unity中官方文档的一个操纵关键词 Platform Dependent Compilation 2,常用的预编译关键词 UNITY_EDITOR 编辑器调用.UNITY_STA ...
- jQuery/js 正则收集(邮件验证、)
var reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/; //验证邮箱的正则表达式if( ...
- Java多线程编程核心技术---拾遗增补
线程状态验证 public class MyThread extends Thread { public MyThread() { System.out.println("构造方法中的状态: ...