CF878D D. Magic Breeding bitset】的更多相关文章

[CF878D]Magic Breeding 题意:有k个物品,每个物品有n项属性值,第i个人的第j个属性值为aij,有q个操作: 1 x y 用x和y合成一个新的物品,新物品的编号是++k,新物品的每项属性值为x和y的对应项的属性值中的较大值.2 x y 用x和y合成一个新的物品,新物品的编号是++k,新物品的每项属性值为x和y的对应项的属性值中的较小值.3 x y 询问x物品的属性y的值. n,q<=100000,k<=12,aij<=10^9 题解:神题,很容易让人想到排序那道题,…
D. Magic Breeding time limit per test 4 seconds memory limit per test 1024 megabytes input standard input output standard output Nikita and Sasha play a computer game where you have to breed some magical creatures. Initially, they have kcreatures num…
D. Magic Breeding link http://codeforces.com/contest/878/problem/D description Nikita and Sasha play a computer game where you have to breed some magical creatures. Initially, they have k creatures numbered from 1 to k. Creatures have n different cha…
对于每一行,用一个2^12个01来表示,其中这一行就是其中所有为1的点所代表的行(i二进制中包含的行)的max的min,然后就可以支持取max和min了,查询只需要枚举答案即可 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define N 100005 4 bitset<5005>f[N]; 5 int n,m,q,p,x,y,a[21][N],id[N][21]; 6 bool cmp(int x,int y){ 7 r…
题面传送门 很容易发现一件事情,那就是数组的每一位都是独立的,但由于这题数组长度 \(n\) 很大,我们不能每次修改都枚举每一位更新其对答案的贡献,这样复杂度必炸无疑.但是这题有个显然的突破口,那就是 \(k\) 的取值范围很小,最高只有 \(12\),也就是说每一位的取值最多只有 \(12\) 种可能,我们考虑以此为突破口,设计一个与这 \(k\) 个数的具体取值无关的状态. 首先我们知道每一位是独立的,故我们可以把每一位拆开来考虑,于是问题由二维变成一维:给定 \(k\) 个数 \(a_1,…
题目链接  Magic Matrix 考虑第三个条件,如果不符合的话说明$a[i][k] < a[i][j]$ 或 $a[j][k] < a[i][j]$ 于是我们把所有的$(a[i][j], i, j)$升序排序,然后检查当前的三元组$(a[i][j], i, j)$的时候, 先确保第一维值小于他的所有三元组$(x, y, z)$中$f[y][z]$已经设置成$1$ 然后看$f[i]$和$f[j]$是否有交集,如果有则说明不符合题意. #include <bits/stdc++.h&g…
题面传送门 开始挖老祖宗(ycx)留下来的东西.jpg 本来想水一道紫题作为 AC 的第 500 道紫题的,结果发现点开了道神题. 首先先讲一个我想出来的暴力做法.条件一和条件二直接扫一遍判断掉.先将所有点按照 \(a_{i,j}\) 按权值大小从小到大排序并依次插入这些点,我们实时维护一个 \(n\times n\) 的 bool 数组 \(vis\),\(vis_{i,j}\) 表示第 \(i\) 行第 \(j\) 列的数是否被访问了.当我们插入某个 \(a_{i,j}\) 时,如果 \(\…
http://acm.hdu.edu.cn/showproblem.php?pid=4605 可以离线求解 把所以可能出现的 magic ball  放在一个数组里(去重),从小到大排列 先不考虑特殊情况,对二叉树进行dfs 搜索的过程中需要维护各个magic ball到当前节点的概率 维护:根据当前节点大小 和要去左子树还是右子树的情况,可以得到magic数组中哪个段的x和y需要同时加上多少 可以用线段树维护 特殊情况: 1,根节点一定可以到达 2,到达不了的情况需要标记 代码: #inclu…
题目链接 给一个n*n的矩阵, 问是否对角线上的元素全都为0, a[i][j]是否等于a[j][i], a[i][j]是否小于等于max(a[i][k], a[j][k]), k为任意值. 前两个都好搞, 我们来看第三个. 第三个的意思是, 对于a[i][j], 它小于等于第i行和第j行每一列的两个元素的最大值. 我们将矩阵中的每一个元素的值以及x, y坐标都加到一个数组里面, 然后从小到大排序. 从0到n-1枚举每一个i, 如果一个元素pos比i小, 那么就将b[pos的x][pos的y]这个…
主题链接: http://acm.hdu.edu.cn/showproblem.php?pid=4016 Magic Bitwise And Operation Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others) Total Submission(s): 1315    Accepted Submission(s): 504 Problem Description Given n…
这个题就是求出给的公式的结果. 仅仅要知道异或运算满足交换律跟结合律即可了.之后就是化简公式. #include<map> #include<string> #include<cstring> #include<cstdio> #include<cstdlib> #include<cmath> #include<queue> #include<vector> #include<iostream> #…
Magic boy Bi Luo with his excited tree Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1058    Accepted Submission(s): 308 Problem Description Bi Luo is a magic boy, he also has a migic tree,…
You're given a matrix A of size n × n. Let's call the matrix with nonnegative elements magic if it is symmetric (so aij = aji), aii = 0 and aij ≤ max(aik, ajk) for all triples i, j, k. Note that i, j, k do not need to be distinct. Determine if the ma…
源代码里有一段: unsigned char map[32]; /* Clear control map */ for (count = 0; count < 32; count++) map[count] = 0; /* Set bits in delimiter table */ do { map[*ctrl >> 3] |= (1 << (*ctrl & 7)); } while (*ctrl++); 这段代码用于计算哪些字符需要分割.map实际上是一个压缩过的…
题目链接 题意: 一棵以1为根的树,树上每个节点有颜色标记(<=60),有两种操作: 1. 可以把某个节点的子树的节点(包括本身)都改成某种颜色 2. 查询某个节点的子树上(包括本身)有多少个不同的颜色 思路: 和2012年多校第7场的G题是同类题,DFS序处理出每个节点管辖的管辖范围[L[u], R[u]],其中L[u]就是子树根节点u所在的位置,用线段树成端更新颜色变化,注意到颜色(<=60),可以用bitset<60>,0表示没有这个颜色,1表示有,异或就能区间合并,最后co…
D. Magic Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Consider the decimal presentation of an integer. Let's call a number d-magic if digit d appears in decimal presentation of…
A magic index in an array A[0...n-1] is defined to be an index such that A[i] = i. Given a sorted array of distinct integers, write a method to find a magic index, if one exists, in array A. FOLLOW UP What if the values are not distinct? public int g…
督促读书,总结精华,提炼笔记,抛砖引玉,有不合适的地方,欢迎留言指正. //开头 #include <bitset> using std::bitset; 问题1.标准库bitset类型(模版) 需要处理二进制位的时候,可以使用c++标准库提供的bitset类型,它也是类模版,类似vectro容器,唯一不同的是,bitset类型需要说明长度,使用常量表达式给出的整型字面值或者已经初始化的cosnt对象. bitset<> bit;//从0到31位算的,bit的32位每位初始化为0…
C++11之后,bitset的构造函数新加了两种形式: bitset<bits>::bitset (const string& str, string::size_type str_idx, string::size_type str_num, string::charT zero) bitset<bits>::bitset (const string& str, string::size_type str_idx, string::size_type str_nu…
自从c++11起,bitset用于unordered container,将会提供默认的hash函数. 在gcc中,相关代码如下: // DR 1182. /// std::hash specialization for bitset. template<size_t _Nb> struct hash<_GLIBCXX_STD_D::bitset<_Nb>> : public std::unary_function<_GLIBCXX_STD_D::bitset&l…
介绍 在Python中,所有以"__"双下划线包起来的方法,都统称为"Magic Method",例如类的初始化方法 __init__ ,Python中所有的魔术方法均在官方文档中有相应描述,但是对于官方的描述比较混乱而且组织比较松散.很难找到有一个例子. 构造和初始化 每个Pythoner都知道一个最基本的魔术方法, __init__ .通过此方法我们可以定义一个对象的初始操作.然而,当调用 x = SomeClass() 的时候, __init__ 并不是第一个…
F. Heroes of Making Magic III time limit per test:3 seconds memory limit per test:256 megabytes input:standard input output:standard output I’m strolling on sunshine, yeah-ah! And doesn’t it feel good! Well, it certainly feels good for our Heroes of…
Magic boy Bi Luo with his excited tree Problem Description Bi Luo is a magic boy, he also has a migic tree, the tree has N nodes , in each node , there is a treasure, it's value is V[i], and for each edge, there is a cost C[i], which means every time…
代码: int i = *reinterpret_cast<int*>(&(d += 6755399441055744.0)); 知识点: 1.reinterpret_cast<type_id> expression:type_id 必须是一个指针.引用.算术类型.函数指针或者成员指针.它可以把一个指针转换成一个整数,也可以把一个整数转换成一个指针(先把一个指针转换成一个整数,再把该整数转换成原类型的指针,还可以得到原先的指针值). 只是将bit表示进行了重新解读,不改变位…
Matrix multiplication Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Problem Description Given two matrices A and B of size n×n, find the product of them. bobo hates big integers. So you are only asked to find t…
GT and set Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description You are given N sets.The i−th set has Ai numbers. You should divide the sets into L parts. And each part should have at least one numbe…
题目地址 简要题意: 给出n行m列的0.1矩阵,每次操作可以将任意一行或一列反转,即这一行或一列中0变为1,1变为0.问通过任意多次这样的变换,最多可以使矩阵中有多少个1. 思路分析: 行数比较小,先不考虑对列的操作,将行数的所有情况举出来最多2^10种情况.对于已经固定了对行进行怎样的操作后,这种情况下对列的最优操作就是对每一列,如果此时1比0多就不变,不然就反转.实现在代码中就是一个for循环扫一遍.注意本题反转行.列采用bitset中的flip函数是非常合适的,因为每个数也不是1就是0,恰…
New Features, Feature Enhancements and Behavior ChangesSubforms – Behavior Change for Unsupported Task ModeStarting with this version, if an Online task that is running in a Subform control cannot be executed, the task and the host task will remain o…
Magic xpa 2.5發佈 Magic xpa 2.5 Release Notes Magic xpa 2.5 Release NotesNew Features, Feature Enhancements and Behavior ChangesCall with Destination – Backward Compatibility EnhancementsIn Online, the following scenarios are now possible: Calling a p…
原文地址:https://dzone.com/articles/how-springboot-autoconfiguration-magic-works In my previous post "Why Spring Boot?", we looked at how to create a Spring Boot application, but you may or may not understand what is going on behind the scenes. You…