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 题解: 代码: /** * ┏┓ ┏┓ * ┏┛┗━━━━━━━┛┗━━━┓ * ┃ ┃ * ┃ ━ ...
随机推荐
- 【CSS单位】px、em、rem
1.PX为单位 在Web页面初期制作中,我们都是使用“px”来设置我们的文本,因为他比较稳定和精确.但是这种方法存在一个问题,当用户在浏览器中浏览我们制作的Web页面时,他改变了浏览器的字体大小,这时 ...
- 理解JavaScript数据类型
JavaScript有5种基本数据类型: 数值(number):整数和小数(比如1和3.14) 字符串(string):字符组成的文本(比如"Hello World") 布尔值(b ...
- WEB测试—功能测试
1. 链接测试 1.1 测试点: 是否添加链接 链接页面是否存在 链接页面与需求是否一致:页面的正确性.打开方式 等 一般,该链接测试在集成测试阶段(页面均开发 ...
- python3的print函数
print()函数也可以接受多个字符串,用逗号“,”隔开,就可以连成一串输出: >>> print('The quick brown fox', 'jumps over', 'the ...
- Jupyter Notebook 设置黑色背景主题、字体大小、代码自动补全
1.背景主题.字体大小设置 安装Jupyter主题: pip install jupyterthemes 然后,更新Jupyter主题: pip install --upgrade jupyterth ...
- bootstrap table 解析写死的json.并且把进度条放进列中。
function showPhaseInfo(phase){ //json字符串转json对象 var phaseInfo = eval(phase); $('#phaseTable').bootst ...
- python 在线生成文字云
在线生成文字云 在线生成文字云地址 http://a.leechg.com:8080/wordcloud 效果图 大体步骤 1 接收请求中的文本,通过结巴分词处理文本. seg_generator ...
- 移动端web开发技巧和常见问题
常见问题 1.移动端如何定义字体font-family 三大手机系统的字体: ios 系统 默认中文字体是Heiti SC 默认英文字体是Helvetica 默认数字字体是HelveticaNeue ...
- Xcode7解决VVDocumenter 不能使用的方案
Xcode7解决VVDocumenter 不能使用的方案 VVDocumenter-Xcode是Xcode上一款快速添加标准注释,并可以自动生成文档的插件.有了VVDocumenter-Xcode,规 ...
- 【Oracle】Oracle安装配置、创建数据库实例及用户和连接
https://blog.csdn.net/wudiyong22/article/details/78904361 参考资料:https://www.cnblogs.com/hoobey/p/6010 ...