1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 `// Artur Kraska, II UWr #include #define forr(i, n) for(int i=0; i=b; i--) #define MP make_pair #define PB push_back #define deb(X) X; //#define M 1000000007 #define INF 1000000007 using namespace std; int n, a, tab[1007], S, d[1007]; long long wynik[107], minn[107], m[107], w[107], mnoz[107]; // dodac longlongi przy 1<>i)&1)+'0'; return s; } void wkladaj(int nr, int ile) { nr += S; while(nr > 0) { d[nr] += ile; nr >>= 1; } } int zlicz(int nr) { int res = 0; nr += S; while(nr > 0) { if((nr & 1) == 0) res += d[nr+1]; nr >>= 1; } return res; } void licz(long long nr, int ile, int kl, long long mask, int mn) { if(nr == n) { if(kl < minn[ile]) { minn[ile] = kl; wynik[ile] = mn; } else if(kl == minn[ile]) wynik[ile] += mn; return ; } bool spr = 1; mnoz[nr] = 1; forr(i, nr) { if((mask & (1LL< tab[j]) { m[i] |= (1LL<