The 2018 ACM-ICPC Asia Qingdao Regional Contest K XOR Clique
K XOR Clique
BaoBao has a sequence a1,a2,...,an. He would like to find a subset S of {1,2,...,n} such that ∀i,j∈S, ai⊕aj<min(ai,aj) and ∣S∣ is maximum, where ⊕ means bitwise exclusive or.
Input
There are multiple test cases. The first line of input contains an integer T, indicating the number of test cases. For each test case:
The first line contains an integer n (1≤n≤105), indicating the length of the sequence.
The second line contains n integers: a1,a2,...,an (1≤ai≤109), indicating the sequence.
It is guaranteed that the sum of n in all cases does not exceed 105.
Output
For each test case, output an integer denoting the maximum size of S.
Sample Input
3
3
1 2 3
3
1 1 1
5
1 2323 534 534 5
Sample Output
2给出n个数字,要求输出一个最长集合的长度,在这个集合中任意两个数两两异或后结果比原来小
3
2
相当于集合中每个数的二进制形式长度相等
#include<bits/stdc++.h>
using namespace std;
int s[];
int bit_width(unsigned int n)
{
unsigned int i = ; do {
++i;
} while ((n >> i)); return i;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n,a;
scanf("%d",&n);
memset(s,,sizeof(s));
int len1,len2,num=,maxx=;
for(int i=;i<n;i++)
{
scanf("%d",&a);
len1=bit_width(a);
s[len1]++; }
for(int i=;i<;i++)
{
maxx=max(maxx,s[i]);
}
printf("%d\n",maxx);
}
return ;
}
The 2018 ACM-ICPC Asia Qingdao Regional Contest K XOR Clique的更多相关文章
- Gym - 101981K The 2018 ICPC Asia Nanjing Regional Contest K.Kangaroo Puzzle 暴力或随机
题面 题意:给你1个20*20的格子图,有的是障碍有的是怪,你可以每次指定上下左右的方向,然后所有怪都会向那个方向走, 如果2个怪撞上了,就融合在一起,让你给不超过5w步,让所有怪都融合 题解:我们可 ...
- The 2018 ACM-ICPC Asia Qingdao Regional Contest(部分题解)
摘要: 本文是The 2018 ACM-ICPC Asia Qingdao Regional Contest(青岛现场赛)的部分解题报告,给出了出题率较高的几道题的题解,希望熟悉区域赛的题型,进而对其 ...
- The 2018 ACM-ICPC Asia Qingdao Regional Contest
The 2018 ACM-ICPC Asia Qingdao Regional Contest 青岛总体来说只会3题 C #include<bits/stdc++.h> using nam ...
- ACM ICPC Central Europe Regional Contest 2013 Jagiellonian University Kraków
ACM ICPC Central Europe Regional Contest 2013 Jagiellonian University Kraków Problem A: Rubik’s Rect ...
- 2019-2020 ICPC, Asia Jakarta Regional Contest (Online Mirror, ICPC Rules, Teams Preferred)
2019-2020 ICPC, Asia Jakarta Regional Contest (Online Mirror, ICPC Rules, Teams Preferred) easy: ACE ...
- The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online J - Press the Button(思维)
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4056 题意 有一个按钮.一个灯.一个计时器和一个计数器,每按一次按钮,计时 ...
- The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online -C:Halting Problem(模拟)
C Halting Problem In computability theory, the halting problem is the problem of determining, from a ...
- The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online Solution
A Live Love 水. #include<bits/stdc++.h> using namespace std; typedef long long ll; ; const i ...
- 2018-2019, ICPC, Asia Yokohama Regional Contest 2018 K
传送门:https://codeforces.com/gym/102082/attachments 题解: 代码: /** * ┏┓ ┏┓ * ┏┛┗━━━━━━━┛┗━━━┓ * ┃ ┃ * ┃ ━ ...
随机推荐
- struts2不同版本在核心filter在web.xml中的配置
FilterDispatcher是struts2.0.x到2.1.2版本的核心过滤器.配置如下: <filter> <filter-name>struts2</filte ...
- rfcn校招总结
idea:ROI pooling前都是卷积,是具备平移不变性的,但一旦插入ROI pooling之后,后面的网络结构就不再具备平移不变性了,就解决了分类和定位的矛盾,但因为引入roi-wise lay ...
- angular.js和ionic框架搭建一个webApp
原文地址:http://www.jianshu.com/p/ea0dcf1d31c9
- inode的理解
迫于需要理解sock_init()中的init_inodecache,所以稍微学习了一下inode. 一.inode的定义 文件储存在硬盘上,硬盘的最小存储单位叫做"扇区"(Sec ...
- git终端操作
1.提交 git add . git commit -m "test" git push origini master 2.分支 创建feature_x分支,并切换到feature ...
- STM32F103 ucLinux开发之二(内核启动汇编代码分析)
start_kernel之前的汇编代码分析 Boot中执行下面两句话之后,进入uclinux内核. theKernel = (void (*)(int, int, unsigned int))((ui ...
- if else 和 switch的效率
switch在判断分支时,没有判断所有的可能性,而是用一个静态表来解决这个问题,所以速度要比if-else快. 但是,switch对较复杂的表达式进行判断,所以当我们需要判断一些简单数值时,用swit ...
- javascript入门教程 (2)
这篇我就不铺垫和废话了,我们开始正式进入JS核心语法的学习… 首先我们从基础入手... 一. 基础语法 1.1 区分大小写 JS语法规定变量名是区分大小写的 比如: 变量名 learninpro 和变 ...
- 协议类接口 - LCD
一.引脚含义 下图为某LCD相关引脚: 从引脚可以大概看出其SoC的连接情况: 1)VCLK为时钟,每一次像素就移动一次 2)HSYNC/VLINE 3)VSYNC/VFRAME 4)VD0 - VD ...
- hdu 1394 Minimum Inversion Number(逆序数对) : 树状数组 O(nlogn)
http://acm.hdu.edu.cn/showproblem.php?pid=1394 //hdu 题目 Problem Description The inversion number ...