标签:blog os io ar for 2014 art div log
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 _(:зゝ∠)_ 随机输出保平安
标签:blog os io ar for 2014 art div log
原文地址:http://www.cnblogs.com/hrhguanli/p/3946675.html