GG,,,g艹

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <math.h>
using namespace std;
vector<int>G[21][7];//G[i][j] 表示n=i k=j的情况下 二进制的状态
int n, k, l;
int a[21], d[6], val[6];
int vis[150], tim;
int work(int x){
int i = 0, j = 0;
while(x) {
if(x&1) d[i++] = j;//a[j]
j++;
x>>=1;
}
int ans = 0;
do
{
memset(val, 0, sizeof val);
tim ++;
int st = 0;
for(int num = 0; num < k; num++) {
i = st; j = 0;
while(1) {
val[j] ^= a[d[i]];
vis[val[j]] = tim;
i++; j++;if(i>=k)i=0;
if(i==st)break;
}
st++;
}
for(i = l; ; i++)
if(vis[i]!=tim)
{
ans = max(ans, (i-1)>=l? (i-1):0);
break;
}
} while (next_permutation(d + 1, d + k));
return ans;
}
void dfs(int dep, int cnt, int num) {
if (dep > 20 || cnt > 6) return ;
G[dep][cnt].push_back(num);
dfs(dep + 1, cnt + 1, num | (1 << dep));
dfs(dep + 1, cnt, num);
} struct Node {
int cnt, idx;
bool operator < (const Node &rhs) const {
return cnt > rhs.cnt;
}
}; Node qq[24];
int b[24]; int cmp(int a, int b) {
return a > b;
} int main(){
int i, j;
for(i = 1; i <= 20; i++)
for(j = 1; j <= 6; j++) G[i][j].clear();
dfs(0, 0, 0);
tim = 100;
while(~scanf("%d %d %d",&n, &k, &l)) {
for(i = 0; i < n; i++)scanf("%d",&a[i]); int ans = 0, siz = (int)G[n][k].size();
if (siz <= 12000) {
for (int i = 0; i < siz; ++i) {
int cur = G[n][k][i];
ans = max(ans, work(cur));
}
} else if (siz <= 24001) {
for (int i = 1; i < siz; i += 2) {
int cur = G[n][k][i];
ans = max(ans, work(cur));
}
} else {
for (int i = 0; i < siz; i += 3) {
int cur = G[n][k][i];
ans = max(ans, work(cur));
}
} printf("%d\n",ans);
}
return 0;
}

HDU 4876 ZCC loves cards _(:зゝ∠)_ 随机输出保平安的更多相关文章

  1. HDU 4876 ZCC loves cards(暴力剪枝)

    HDU 4876 ZCC loves cards 题目链接 题意:给定一些卡片,每一个卡片上有数字,如今选k个卡片,绕成一个环,每次能够再这个环上连续选1 - k张卡片,得到他们的异或和的数,给定一个 ...

  2. hdu 4876 ZCC loves cards(暴力)

    题目链接:hdu 4876 ZCC loves cards 题目大意:给出n,k,l,表示有n张牌,每张牌有值.选取当中k张排列成圈,然后在该圈上进行游戏,每次选取m(1≤m≤k)张连续的牌,取牌上值 ...

  3. HDOJ 4876 ZCC loves cards

    枚举组合,在不考虑连续的情况下推断能否够覆盖L...R,对随机数据是一个非常大的减枝. 通过检測的暴力计算一遍 ZCC loves cards Time Limit: 4000/2000 MS (Ja ...

  4. hdu 4873 ZCC Loves Intersection(大数+概率)

    pid=4873" target="_blank" style="">题目链接:hdu 4873 ZCC Loves Intersection ...

  5. 多校训练赛2 ZCC loves cards

    ZCC loves cards Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  6. HDU 4873 ZCC Loves Intersection(可能性)

    HDU 4873 ZCC Loves Intersection pid=4873" target="_blank" style="">题目链接 ...

  7. hdu 4882 ZCC Loves Codefires(数学题+贪心)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4882 ------------------------------------------------ ...

  8. hdu 5288 ZCC loves straight flush

    传送门 ZCC loves straight flush Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K ...

  9. HDU 5228 ZCC loves straight flush( BestCoder Round #41)

    题目链接:pid=5228">ZCC loves straight flush pid=5228">题面: pid=5228"> ZCC loves s ...

随机推荐

  1. [置顶] Android4.x对长按电源键(挂断键)和短按电源键(挂断键)的详细处理流程

    1. 简介 Android4.x在Framework的PhoneWindowManager对Power(KeyEvent.KEYCODE_POWER)和Home(KeyEvent.KEYCODE_HO ...

  2. oracle scn浅析

    1. 系统SCN号 查询系统SCN号的方法: select dbms_flashback.get_system_change_number from dual commit后系统SCN号会增长,但是即 ...

  3. IOS 获取网络图像尺寸 更改 图像色彩值 什么一套方法灰色

    直接在代码 头文件 // 图片处理 0 半灰色 1 灰度 2 深棕色 3 反色 +(UIImage*)imageWithImage:(UIImage*)image grayLevelType:(UII ...

  4. [leetcode] Reverse Linked List 分类: leetcode 算法 2015-07-09 18:44 2人阅读 评论(0) 收藏

    反转链表:比较简单的问题,可以遍历也可以递归. # Definition for singly-linked list. class ListNode: def __init__(self, x): ...

  5. c++ 重载,覆盖,重定义

    写的不是很明白,后来又重新整理过了,在: http://www.cnblogs.com/iois/p/4986790.html 函数重载(Function Overloading) C++允许同一范围 ...

  6. oracle 11gR2 在VM中安装步骤

    oacle的安装 一.在oracle官网可以免费下载oracle的软件和安装文档,如果是在虚拟机中的linux系统里安装,可以用FileZilla Client把软件发送到系统中. linux_11g ...

  7. codeforces 487E Tourists

    如果不是uoj上有的话(听说这是China Round),我有可能就错过这道题目了(这是我有史以来为oi写的最长的代码,用了我一天TAT!). 题目 传送门. 一个连通无向图,点上有权,支持两种操作: ...

  8. Ext的异步请求(二级级联动态加载下拉列表)

    页面: <tr> <td class="label" width="300" >作业计划项模板</td> <td> ...

  9. linux c setitimer使用方法说明

    在linux c编程中.setitimer是一个比較经常使用的函数.可用来实现延时和定时的功能,网上有各种零零散散的使用方法说明,都仅仅提到了个别使用方法,今天抽出时间实践整理了一份比較具体的: 使用 ...

  10. JIRA初步

    JIRA 是澳大利亚 Atlassian 公司开发的一款优秀的问题跟踪管理软件工具.可以对各种类型的问题进行跟踪管理.包含缺陷.任务.需求.改进等.JIRA採用J2EE技术.可以跨平台部署.它正被广泛 ...