GG, g average
# 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] indicates the binary state int N, K, L when n = I k = J; 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 Mai N () {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", & 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 _ (: Random outputs) _ random output to ensure security