QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#449746 | #8598. AND Масив | arbuzick# | 0 | 4215ms | 16768kb | C++20 | 1.9kb | 2024-06-21 16:45:48 | 2024-06-21 16:45:50 |
Judging History
answer
#include <bits/extc++.h>
using namespace std;
constexpr int maxb = 20;
int pos[1 << maxb];
int vl1[1 << maxb], vl2[1 << maxb];
void solve() {
int n, b;
cin >> n >> b;
vector<int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
int part1 = 14;
if (part1 > b) {
part1 = b;
}
for (int i = 0; i < (1 << b); ++i) {
pos[i] = n;
vl1[i] = (((i ^ ((1 << b) - 1)) >> (b - part1)) << (b - part1));
vl2[i] = (i ^ ((1 << b) - 1)) - vl1[i];
}
vector<long long> ans(n);
long long sum_zero = 0;
for (int i = n - 1; i >= 0; --i) {
if (a[i] != 0) {
int val1 = (a[i] >> (b - part1)), val2 = (a[i] & ((1 << (b - part1)) - 1));
for (int j = 0; j < (1 << part1); ++j) {
if ((val1 & j) == val1) {
pos[(j << (b - part1)) + val2] = i;
}
}
} else {
sum_zero += a[i] + 1;
}
ans[i] = sum_zero * b;
for (int st = 0; st < b; ++st) {
int val_nw = (1 << st);
while (true) {
int nxt = n;
int val1 = vl1[val_nw], val2 = vl2[val_nw];
for (int j = 0; j < (1 << (b - part1)); ++j) {
if ((val2 & j) == val2) {
nxt = min(nxt, pos[val1 + j]);
}
}
if (nxt == n) {
break;
}
val_nw |= a[nxt];
ans[i] += nxt + 1;
}
}
}
for (int i = 0; i < n; ++i) {
cout << ans[i] << ' ';
}
cout << '\n';
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 27ms
memory: 15904kb
input:
2000 20 251931 620255 725521 330111 783060 690627 489092 1019106 84341 631993 231500 920886 604265 342966 152434 588032 469990 805072 809795 12697 699326 433747 754394 567737 603087 199524 539078 775214 872735 454953 106496 93877 933762 36223 211878 168057 53977 782675 171782 455544 869778 47128 955...
output:
14722 14722 14692 14615 20415 20415 20415 20415 20415 20415 20415 20415 20415 20415 20415 20415 20415 20415 20415 20415 15621 12061 12061 12061 12061 12061 12061 12061 12061 12368 12368 12368 12368 12368 35981 35981 35981 35981 35981 35981 35981 35981 34683 34683 34683 34683 34683 34683 34683 35181 ...
result:
wrong answer 1st lines differ - expected: '10212 4259 4815 9101 17193 176...6 39925 39961 39974 43987 18000', found: '14722 14722 14692 14615 20415 ... 1990 1990 0 0 0 0 0 0 0 0 0 0 '
Subtask #2:
score: 0
Wrong Answer
Test #4:
score: 0
Wrong Answer
time: 4215ms
memory: 16768kb
input:
100000 20 262144 16 65536 8 256 1024 32 262144 16 262144 256 1024 1 64 2 131072 4096 2048 2 32 8192 4 2 262144 32768 1 524288 262144 262144 2048 8 64 1 2 8192 131072 256 64 8192 1 262144 4 32 4 524288 1 32768 16 64 128 8192 16 32 4096 16384 16384 4 131072 32768 16384 131072 2 16 2048 32768 16 4 4096...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
wrong answer 1st lines differ - expected: '7752 7885 8018 9329 9842 9956 ...7599886 5699943 3799981 1900000', found: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 '
Subtask #3:
score: 0
Wrong Answer
Test #6:
score: 0
Wrong Answer
time: 47ms
memory: 8504kb
input:
100000 8 98 78 5 190 79 234 162 79 118 176 115 130 10 9 233 56 97 15 148 13 46 87 92 65 150 62 50 46 159 101 48 86 203 71 29 124 23 228 55 161 240 80 139 74 251 143 167 207 183 52 50 252 17 185 40 145 167 164 227 166 172 60 182 62 173 227 232 243 251 134 109 241 44 33 217 149 51 6 110 201 242 196 23...
output:
6465 4939 4809 5747 6219 6806 5471 6417 6414 5465 5980 7016 6276 5848 5866 5555 6016 5806 6115 5957 5846 5821 6590 5954 6637 6926 7105 7102 6699 7375 6480 6665 6257 6086 6488 7026 6119 6386 5703 5916 7066 5722 6551 6357 6421 6507 6120 5460 5615 7091 6854 6290 6486 6979 7150 7827 7752 8438 7759 7886 ...
result:
wrong answer 1st lines differ - expected: '152631657 152630131 152630001 ...4 1199980 1199981 699995 500000', found: '6465 4939 4809 5747 6219 6806 ... 1199980 1199981 699995 500000 '
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
0%