HDU 4876 ZCC loves cards _(:зゝ∠)_ 随机输出保平安
来源:互联网 发布:u盘损坏数据恢复 编辑:程序博客网 时间:2024/05/10 12:36
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;}
0 0
- HDU 4876 ZCC loves cards _(:зゝ∠)_ 随机输出保平安
- HDU 4876 ZCC loves cards
- HDU-4876-ZCC loves cards
- hdu 4876 ZCC loves cards
- HDU 4876 ZCC loves cards
- HDU 4876 ZCC loves cards
- 【HDU 4876多校】ZCC loves cards【搜索】
- hdu 4876 ZCC loves cards(暴力)
- HDU 4876 ZCC loves cards(暴力剪枝)
- 【HDU】4876 ZCC loves cards 暴力
- hdu 4876 ZCC loves cards (搜索+剪枝)
- HDOJ 4876 ZCC loves cards
- hdu 4876 ZCC loves cards(暴力+剪枝)
- hdu 4876 ZCC loves cards(暴搜+剪枝)
- HDU 4876 ZCC loves cards【暴力+深搜+剪枝】
- [HDOJ 4876] ZCC loves cards [搜索]
- HDOJ 4876 ZCC loves cards(搜索)
- HDU4876 ZCC loves cards
- 马云扎堆谈战略:战和略是不同能力 非人人会懂
- android学习笔记:adb更换端口后成功启动
- NYOJ-42 一笔画问题
- Android Intent Action大全
- Step By Step(Lua目录)
- HDU 4876 ZCC loves cards _(:зゝ∠)_ 随机输出保平安
- SQLite数据库中的SQL语句
- Delphi在调试的时候查看变量的值
- SQLite学习手册(目录)
- Swift源码分析----swift-account-info
- 解决VBOX虚拟机迁移中的虚拟硬盘加载出错问题
- 盘点游戏行业的那些干货网站
- hdu2033 人见人爱A+B
- Tkinter Entry only allows digit number