QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#488326 | #8598. AND Масив | mshcherba# | 20 | 27ms | 4424kb | C++20 | 1.1kb | 2024-07-23 21:13:27 | 2024-07-23 21:13:28 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n, b;
cin >> n >> b;
VI a(n);
for (int& ai : a)
cin >> ai;
if (n <= 2000)
{
FOR(s, 0, n)
{
LL ans = 0;
FOR(p, 0, b)
{
int x = 1 << p;
LL res = 0;
FOR(i, s, n)
{
if ((x & a[i]) == 0)
{
x |= a[i];
res += i + 1;
}
}
ans += res;
}
cout << ans << " ";
}
cout << "\n";
return 0;
}
vector<LL> ans(n);
VI index(b);
RFOR(s, n, 0)
{
index[__builtin_ctz(a[s])] = s + 1;
LL sum = accumulate(ALL(index), 0LL);
ans[s] = sum * (b - 1);
}
FOR(s, 0, n)
cout << ans[s] << " ";
cout << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 25ms
memory: 3608kb
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:
10212 4259 4815 9101 17193 17617 22629 16642 10432 10731 11766 20234 27120 17990 24654 22106 18877 14050 9217 10109 4283 9341 11741 13465 13724 9572 11200 4046 7660 7001 6512 12634 13360 10494 19745 15300 12727 17726 14188 10472 12754 7995 10571 11290 14862 19370 16785 13328 13589 17425 23190 17082 ...
result:
ok single line: '10212 4259 4815 9101 17193 176... 39925 39961 39974 43987 18000 '
Test #2:
score: 10
Accepted
time: 27ms
memory: 3632kb
input:
2000 20 2080 32772 278528 256 2560 1056 528384 2056 132 144 768 98304 36864 262152 262400 81920 264192 16448 294912 786432 8194 16388 9 520 49152 2 262272 20 131584 528384 514 4352 12288 36 32800 72 16392 32 129 8 1028 131080 12288 8193 8320 528 1026 24576 8192 10240 163840 524288 262400 278528 2785...
output:
10532 10275 11389 7400 12269 14740 10975 9199 12307 10890 12090 11861 12707 12449 12586 12195 12260 14273 18795 18089 19280 21369 14169 17819 13755 16253 14945 14538 24799 24439 23275 17968 19797 19977 21225 18864 16595 21665 22140 32768 31494 29782 27849 20911 26304 21480 25191 22840 30738 26969 22...
result:
ok single line: '10532 10275 11389 7400 12269 1...11837 109909 73963 71982 36000 '
Test #3:
score: 10
Accepted
time: 26ms
memory: 3848kb
input:
2000 20 81937 164096 131652 98564 263184 69665 2596 557184 286848 22544 49416 196872 65816 2179 45056 135232 352 1120 8832 32801 131776 98328 528385 51456 266400 396288 65573 328200 528512 26 65700 2248 8328 322 557312 16516 34050 66624 721152 45060 524353 2448 65984 16899 20993 137 265248 33808 665...
output:
10265 12832 12649 13394 14831 13921 19818 8209 7716 12652 12292 11823 12491 12133 17047 7964 8283 15911 12563 12580 12125 10806 12966 12370 19648 11631 12192 16886 17717 20174 20336 25578 15349 16556 21621 20009 14907 18092 15498 24250 21725 21223 14614 15274 10702 16692 16601 15963 14431 23066 1801...
result:
ok single line: '10265 12832 12649 13394 14831 ... 75882 73929 95952 63984 32000 '
Subtask #2:
score: 10
Accepted
Test #4:
score: 10
Accepted
time: 11ms
memory: 4424kb
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:
7752 7885 8018 9329 9842 9956 10070 10317 10355 11096 11362 11856 12958 13205 13547 13623 14003 14706 14934 15010 15447 15713 16093 16302 16378 16796 16929 17271 17290 17518 18164 19114 19228 19361 19893 19969 20387 21147 21356 21584 21698 23332 23370 23560 23807 24510 25688 25916 25992 26486 27322 ...
result:
ok single line: '7752 7885 8018 9329 9842 9956 ...599886 5699943 3799981 1900000 '
Test #5:
score: 10
Accepted
time: 10ms
memory: 4352kb
input:
100000 20 1 8 8 8 8 8 4 8 4 8 2 1 2 1 2 1 4 8 4 2 8 2 1 2 8 4 4 2 1 2 1 4 4 4 2 4 1 8 4 8 1 1 4 2 4 4 8 4 1 8 2 1 2 8 4 8 8 4 2 4 1 2 1 4 4 4 4 1 1 4 8 4 2 2 1 4 8 2 2 4 2 8 8 4 2 1 4 4 8 1 4 4 4 4 8 8 4 8 1 2 1 2 1 1 4 2 8 2 2 2 2 8 2 2 2 4 8 2 8 1 8 4 2 1 1 1 4 8 4 4 8 4 8 2 4 4 4 1 2 4 4 16 1 2 1...
output:
17159147 17159356 17159375 17159394 17159413 17159432 17159470 17159508 17159546 17159698 17159850 17159888 17159926 17159964 17160002 17160097 17160230 17160268 17160325 17160458 17160496 17160572 17160610 17160724 17160800 17161047 17161066 17161161 17161199 17161237 17161332 17161446 17161465 171...
result:
ok single line: '17159147 17159356 17159375 171...899943 1899962 1899981 1900000 '
Subtask #3:
score: 0
Wrong Answer
Test #6:
score: 0
Wrong Answer
time: 9ms
memory: 4376kb
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:
4816 4823 4837 4851 4865 4886 4893 4907 4928 4949 5096 5117 5124 5180 5187 5201 5474 5481 5495 5523 5537 5565 5579 5670 5705 5712 5719 5726 5754 5761 5782 5852 5936 5943 5950 5964 5978 5992 6076 6083 6104 6111 6475 6489 6538 6545 6552 6559 6566 6594 6608 6671 6713 6720 6734 6818 6825 6839 6860 6902 ...
result:
wrong answer 1st lines differ - expected: '152631657 152630131 152630001 ...4 1199980 1199981 699995 500000', found: '4816 4823 4837 4851 4865 4886 ...2099958 1399979 1399993 700000 '
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
0%