QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#449433 | #8518. Roars III | luanmenglei | AC ✓ | 885ms | 65336kb | C++17 | 5.2kb | 2024-06-21 10:09:47 | 2024-06-21 10:09:48 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
namespace SOL {
using i64 = long long;
void debug(const char *msg, ...) {
#ifdef CLESIP
va_list arg;
static char pbString[512];
va_start(arg,msg);
vsprintf(pbString,msg,arg);
cerr << "[DEBUG] " << pbString << "\n";
va_end(arg);
#endif
}
template<typename T, typename L>
bool chkmax(T &x, L y) { if (x < y) return x = y, true; return false; }
template<typename T, typename L>
bool chkmin(T &x, L y) { if (y < x) return x = y, true; return false; }
const int N = 2e5 + 10;
const int inf = 1e9;
int n, dfn[N], id[N], sze[N], cnt;
i64 ans[N];
char str[N];
vector<int> adj[N];
const int SEG_SIZE = N * 4;
struct SegTree {
#define lc (x * 2)
#define rc (x * 2 + 1)
#define mid ((l + r) >> 1)
int tag[SEG_SIZE];
array<int, 2> cnt[SEG_SIZE], mx[SEG_SIZE];
i64 sum[SEG_SIZE];
void pull(int x) {
mx[x] = max(mx[lc], mx[rc]);
sum[x] = sum[lc] + sum[rc];
for (int op : { 0, 1 })
cnt[x][op] = cnt[lc][op] + cnt[rc][op];
}
void apply(int x, int k) {
tag[x] += k;
sum[x] += 1ll * k * (cnt[x][0] - cnt[x][1]);
mx[x][0] += k;
}
void push(int x) {
if (tag[x]) {
apply(lc, tag[x]);
apply(rc, tag[x]);
tag[x] = 0;
}
}
void build(int x, int l, int r) {
mx[x] = { -inf, 0 };
if (l == r) return;
build(lc, l, mid), build(rc, mid + 1, r);
}
void set(int x, int l, int r, int p, int op, int k) {
if (l == r) {
cnt[x][op] = k;
if (cnt[x][1])
mx[x] = { tag[x], p };
else
mx[x] = { -inf, 0 };
sum[x] = tag[x] * (cnt[x][0] - cnt[x][1]);
return;
}
push(x);
p <= mid ? set(lc, l, mid, p, op, k) : set(rc, mid + 1, r, p, op, k);
pull(x);
}
void add(int x, int l, int r, int ql, int qr, int k) {
if (ql > qr)
return;
if (ql <= l && r <= qr)
return apply(x, k);
push(x);
if (ql <= mid)
add(lc, l, mid, ql, qr, k);
if (mid < qr)
add(rc, mid + 1, r, ql, qr, k);
pull(x);
}
array<int, 2> query_max(int x, int l, int r, int ql, int qr) {
if (ql > qr)
return { -inf, 0 };
if (ql <= l && r <= qr)
return mx[x];
push(x);
if (ql <= mid && mid < qr)
return max(query_max(lc, l, mid, ql, qr), query_max(rc, mid + 1, r, ql, qr));
else
return ql <= mid ? query_max(lc, l, mid, ql, qr) : query_max(rc, mid + 1, r, ql, qr);
}
void debug_print(int x, int l, int r) {
if (l == r) {
debug("pos: %d x: %d (%d, %d) dep: %d", l, id[l], cnt[x][0], cnt[x][1], tag[x]);
return;
}
push(x);
debug_print(lc, l, mid);
debug_print(rc, mid + 1, r);
}
#undef lc
#undef rc
#undef mid
} segt;
int pos[N];
void dfs1(int x, int p) {
dfn[x] = ++ cnt, id[dfn[x]] = x, sze[x] = 1;
for (int y : adj[x]) if (y != p) {
dfs1(y, x);
segt.add(1, 1, n, dfn[y], dfn[y] + sze[y] - 1, 1);
sze[x] += sze[y];
}
if (str[x] == '0') {
auto res = segt.query_max(1, 1, n, dfn[x], dfn[x] + sze[x] - 1);
if (res[1] != 0) {
pos[x] = id[res[1]];
segt.set(1, 1, n, dfn[pos[x]], 1, 0);
segt.set(1, 1, n, dfn[x], 1, 1);
}
} else {
segt.set(1, 1, n, dfn[x], 0, 1);
segt.set(1, 1, n, dfn[x], 1, 1);
}
}
void dfs2(int x, int p) {
// cerr << "visit " << x << "\n";
// segt.debug_print(1, 1, n);
ans[x] = segt.sum[1];
for (int y : adj[x]) if (y != p) {
int tmpx = 0, tmpy = 0;
if (pos[x]) {
segt.set(1, 1, n, dfn[x], 1, 0);
segt.set(1, 1, n, dfn[pos[x]], 1, 1);
}
if (pos[y]) {
segt.set(1, 1, n, dfn[y], 1, 0);
segt.set(1, 1, n, dfn[pos[y]], 1, 1);
}
segt.add(1, 1, n, dfn[y], dfn[y] + sze[y] - 1, -1);
segt.add(1, 1, n, 1, dfn[y] - 1, 1);
segt.add(1, 1, n, dfn[y] + sze[y], n, 1);
if (str[x] == '0') {
auto res = max(segt.query_max(1, 1, n, 1, dfn[y] - 1), segt.query_max(1, 1, n, dfn[y] + sze[y], n));
if (res[1] != 0) {
tmpx = id[res[1]];
segt.set(1, 1, n, dfn[tmpx], 1, 0);
segt.set(1, 1, n, dfn[x], 1, 1);
}
}
if (str[y] == '0') {
auto res = segt.mx[1];
// debug("%d => %d (%d, %d)", x, y, res[0], res[1]);
if (res[1] != 0) {
tmpy = id[res[1]];
segt.set(1, 1, n, dfn[tmpy], 1, 0);
segt.set(1, 1, n, dfn[y], 1, 1);
}
}
swap(pos[x], tmpx);
swap(pos[y], tmpy);
dfs2(y, x);
swap(pos[x], tmpx);
swap(pos[y], tmpy);
if (tmpy) {
segt.set(1, 1, n, dfn[y], 1, 0);
segt.set(1, 1, n, dfn[tmpy], 1, 1);
}
if (tmpx) {
segt.set(1, 1, n, dfn[x], 1, 0);
segt.set(1, 1, n, dfn[tmpx], 1, 1);
}
segt.add(1, 1, n, dfn[y], dfn[y] + sze[y] - 1, 1);
segt.add(1, 1, n, 1, dfn[y] - 1, -1);
segt.add(1, 1, n, dfn[y] + sze[y], n, -1);
if (pos[y]) {
segt.set(1, 1, n, dfn[pos[y]], 1, 0);
segt.set(1, 1, n, dfn[y], 1, 1);
}
if (pos[x]) {
segt.set(1, 1, n, dfn[pos[x]], 1, 0);
segt.set(1, 1, n, dfn[x], 1, 1);
}
}
}
void solve() {
cin >> n >> (str + 1);
for (int i = 1, x, y; i < n; i ++) {
cin >> x >> y;
adj[x].push_back(y), adj[y].push_back(x);
}
segt.build(1, 1, n);
dfs1(1, 0);
dfs2(1, 0);
for (int i = 1; i <= n; i ++)
cout << ans[i] << " \n"[i == n];
}
}
int main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
SOL::solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 16016kb
input:
5 10101 1 2 2 3 2 4 4 5
output:
2 2 2 3 3
result:
ok 5 number(s): "2 2 2 3 3"
Test #2:
score: 0
Accepted
time: 2ms
memory: 11920kb
input:
1 0
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: 0
Accepted
time: 0ms
memory: 15924kb
input:
1 1
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: 0
Accepted
time: 0ms
memory: 13900kb
input:
2 10 1 2
output:
0 1
result:
ok 2 number(s): "0 1"
Test #5:
score: 0
Accepted
time: 2ms
memory: 13896kb
input:
3 100 2 3 2 1
output:
0 1 2
result:
ok 3 number(s): "0 1 2"
Test #6:
score: 0
Accepted
time: 0ms
memory: 13912kb
input:
4 1100 4 1 4 3 4 2
output:
1 1 3 1
result:
ok 4 number(s): "1 1 3 1"
Test #7:
score: 0
Accepted
time: 0ms
memory: 13904kb
input:
5 10100 4 5 1 3 2 1 3 5
output:
0 2 0 4 2
result:
ok 5 number(s): "0 2 0 4 2"
Test #8:
score: 0
Accepted
time: 2ms
memory: 17968kb
input:
8 11001000 4 2 7 2 5 7 6 2 3 1 6 3 7 8
output:
5 3 5 5 4 4 4 6
result:
ok 8 numbers
Test #9:
score: 0
Accepted
time: 0ms
memory: 15932kb
input:
64 1110101001010110011100110000010100011011010001000111010110100101 57 60 58 63 7 43 64 9 19 8 62 17 4 40 41 18 34 56 46 14 41 36 57 26 46 58 16 32 59 1 8 17 17 13 34 29 55 10 43 5 34 8 28 36 6 10 37 21 11 48 2 8 56 55 3 8 56 61 53 52 49 51 20 30 52 39 57 22 9 49 18 16 9 27 50 52 38 40 59 43 2 18 31...
output:
34 29 29 33 34 37 34 29 31 30 49 31 41 33 27 36 34 29 29 27 30 36 30 27 34 36 38 46 29 27 38 36 50 27 33 36 30 33 30 27 36 40 34 34 31 33 38 40 36 30 36 30 37 36 30 27 29 33 34 36 32 34 40 27
result:
ok 64 numbers
Test #10:
score: 0
Accepted
time: 3ms
memory: 15980kb
input:
512 11100000100000011111111011010110001001101100011110001001111001011011000001010000100011011101001001101100010000011100000110101010100001001110000011010000111001000110010011000100000010010000100100000000100001001011100010100100101101010000111100110010001010010011101010001000111001001010111111111101...
output:
229 209 213 228 257 224 211 243 208 238 231 211 246 231 235 206 211 208 220 225 226 206 220 251 215 220 238 234 230 208 215 235 230 220 220 235 233 217 243 250 206 220 221 253 230 206 240 209 208 220 215 251 228 221 228 219 208 208 219 256 221 206 222 208 228 230 208 230 235 241 228 223 231 221 229 ...
result:
ok 512 numbers
Test #11:
score: 0
Accepted
time: 10ms
memory: 18212kb
input:
4096 0011111001111111001000100000001010100111001000010100110000110111011111111001001101101010011010001010111100111110001111000000000111001110100110100011011101110011101111001010011011110101111110000101111111100101101001001000000110100111100010110110011001111111011111100111001101111110110111000010101...
output:
1579 1639 1528 1542 1551 1523 1522 1553 1553 1532 1533 1551 1562 1534 1564 1568 1583 1559 1553 1537 1533 1568 1541 1566 1563 1557 1546 1537 1551 1586 1570 1548 1576 1587 1523 1541 1539 1522 1538 1565 1554 1589 1548 1614 1570 1570 1549 1527 1578 1520 1569 1581 1540 1540 1551 1579 1594 1550 1551 1550 ...
result:
ok 4096 numbers
Test #12:
score: 0
Accepted
time: 78ms
memory: 17728kb
input:
32768 010000100111010011101111111011001000100100101001100000110010100111111101110011000110001011001001100110111010010111000001110101000011101010010101111101001100100011101101010000001011001010100011011011001001111101011000001101101110101010001001011011101001010101010000011111100011110100011000001110...
output:
12964 12950 12999 13070 12980 12974 12927 12949 12952 12953 12999 12962 12972 12972 12951 12989 12948 12971 12930 12954 13012 12972 12946 12985 12946 12926 12996 13037 12915 12915 13011 13017 12939 13055 13044 12986 12986 12984 12968 12958 12960 12973 12981 12976 12992 13011 12991 12930 13001 13018 ...
result:
ok 32768 numbers
Test #13:
score: 0
Accepted
time: 589ms
memory: 40484kb
input:
200000 10010111111100101000010111101000010111110101100011001101010001010011111001000101111110000010001000011111011011100111001110101011010011111001010100110100100100110110100101010111011010010110111000000100100010100010111001011111011010111010111001000101010111010011010000111011001110000100010110001...
output:
76960 76970 77040 76999 77019 77042 77011 76949 77007 76939 76942 77018 77042 77033 76979 77033 77016 77097 77044 77026 76989 77001 77003 76921 77029 76965 77014 76997 76929 77043 77060 76994 76991 76969 76981 76999 77003 76962 76973 76973 77028 76951 77110 77007 76973 77026 76967 77063 76985 76927 ...
result:
ok 200000 numbers
Test #14:
score: 0
Accepted
time: 447ms
memory: 61472kb
input:
200000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
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:
ok 200000 numbers
Test #15:
score: 0
Accepted
time: 700ms
memory: 61280kb
input:
200000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
161492 137521 86353 91682 179554 32952 199999 187698 194579 146953 46676 121254 116117 100440 87715 189200 152989 51997 85956 198765 184369 83564 17495 17817 160444 175764 63191 96898 77717 148773 180625 179211 40055 96933 184676 88548 118706 197000 174795 135984 22745 90516 89377 146233 177451 1998...
result:
ok 200000 numbers
Test #16:
score: 0
Accepted
time: 831ms
memory: 61148kb
input:
200000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998 199998...
result:
ok 200000 numbers
Test #17:
score: 0
Accepted
time: 732ms
memory: 61112kb
input:
199997 10001001111101000110010000100011101000000101001010011000001001000000000011011000010100110010000000011000010000101000000001000110011011010000100111101000101110100001000110001100101011000111000001010010010100110000000111000101101100001000100000100001101100100000110110000011000000000010000010000...
output:
3374373051 4189970859 3184123733 3450268583 2277945377 3696454439 3061951659 3949712041 4220671753 3323963325 2190820273 2815791721 3038430245 2442474205 2679717347 2445099211 4234389437 2761141455 2243098995 3312035333 2354016045 3302499627 3219965331 2883371715 3480709045 2516738855 3524451139 272...
result:
ok 199997 numbers
Test #18:
score: 0
Accepted
time: 565ms
memory: 65336kb
input:
200000 11110001010101111010101000111010011101011110111101111111111111000111110110110001100111011111110111111000111101011101000110111111101101011101111001011011111101110110011110110010110111100111101101110111101111101101110110110111101100010111111011011111111011111101001000111010111111110001011101111...
output:
3725613546 2828499752 2737429131 2045154129 2029946119 3165261139 2911119762 2515530064 2165720641 2144045544 2040045369 2228309145 2901494750 2024811935 3169167665 3707239399 2070360489 2087404270 2988622806 3134475317 2781740246 2029884243 2121709189 2075106780 2130071393 2029683930 2058685522 211...
result:
ok 200000 numbers
Test #19:
score: 0
Accepted
time: 741ms
memory: 51528kb
input:
200000 10110000001010000100000001101000110111100100011000110110011000000110101001000100100100100011100100000000011010000000000010011000000001001010000110001000011101001100010011001000000101011000001000000011100000111111101101000001111001111101011110100101000000010100100010101001000101101010100100001...
output:
1308385941 1497995208 1266404072 1289062935 858619709 1566912729 1017422986 1091038784 1038086490 1223278595 1006222526 1394298647 854966615 885696155 852709442 987838292 955819388 1507851132 1386310224 1364736704 854420649 1482911174 848349724 1408402251 978706570 970316455 849763624 883633108 1681...
result:
ok 200000 numbers
Test #20:
score: 0
Accepted
time: 581ms
memory: 47564kb
input:
199996 11101111111011011110010011111110101110010001101001111111110110110101010111101111011101010110111100010010010001111111111110111110101011111111010001011010110111010111111111111110100111111101001010111110111111011110101101101111010010111111101101101101011111100110111100111110100100101111111011011...
output:
615343737 1203579448 598359583 989298818 812092194 821754366 1141393729 686841808 616557077 603000404 1142668228 970815777 660125467 640379064 704861495 664954666 606549248 830243786 729188396 1010616317 861920504 675376469 958545234 968450580 625221001 928121241 838868630 599726030 976820859 118197...
result:
ok 199996 numbers
Test #21:
score: 0
Accepted
time: 693ms
memory: 41716kb
input:
199996 10111100000001000101001100100001000000010101000100001010011011110011111010000110011000000111100001110100100100110100011000100000001101111001000110101000000011001101000100010001000001001000000000000011010000110011000001000011100100001010011000100000110100000000011011000110001000100011110011011...
output:
132684038 85297098 96153257 84911449 89602811 116755678 119526132 114225882 96352259 127315227 93853753 86267926 84358040 130446546 151042003 91223806 129944661 92092641 144651576 97913533 89929641 100891962 131855104 86215388 97026302 155386765 83682781 86907874 91877668 143176539 137571245 1624191...
result:
ok 199996 numbers
Test #22:
score: 0
Accepted
time: 537ms
memory: 43544kb
input:
200000 10111001011100111111011111011111010111011011111111001101100011110111011110110110001011110110111111011110111111100111011010101011010100110110111000110100111111011111111101101111100111111100001011010101010011110111111010111111100010111100101101101111111110111011111100010111101101011110110111101...
output:
52241949 45612057 66758763 46380544 44818472 46921700 44638963 52621704 64880290 68645356 42929365 43239914 44794025 63440953 56513938 42971337 43490789 47706884 71222729 43527037 45018123 65336871 68797798 61131057 55098211 56130482 84190188 46085989 43795154 44371015 47983026 46447839 67602886 736...
result:
ok 200000 numbers
Test #23:
score: 0
Accepted
time: 681ms
memory: 41436kb
input:
199996 01000011110111000010010010110111000000010001100000110000010001001000111000000101010100100100110001100010100011111100000010100001000100010011011000000001010110010000001111010010100011100010100010100011010000100100010100100000100000000000001110000000011110111111001000110010010011101001110001000...
output:
1590445 1505764 1934106 1502259 1578933 1823018 1843632 2075482 1617726 1639629 1570766 1494660 2025807 1778933 2174614 1550729 1493833 1892533 1549027 1616458 1543018 1678579 1675190 1530761 1975361 1638171 1525275 1623049 1743072 1571282 1795641 2173817 1667816 2044865 1660072 1696001 1584213 1697...
result:
ok 199996 numbers
Test #24:
score: 0
Accepted
time: 574ms
memory: 39612kb
input:
199999 11110111101111011111111010011110111100101101011111111011011110100011111001010101110110111100100100001111000000110100010111100010100110011001111011110011100100111111011111111010011110000011100011010011011111100111010000110111110111111011110111001011111011101001011111011011000000110110001011101...
output:
1335936 1149455 1257202 1246972 1337971 1065686 1055691 1032393 1162844 1297813 1148423 1031473 1039382 1366080 1082199 1014749 1260822 1041626 1229873 1019083 1152778 1048402 1282455 1304657 1124282 1021655 1018792 1200226 1485285 1327574 1040357 1131751 1144021 1027292 1210300 1022144 1165012 1188...
result:
ok 199999 numbers
Test #25:
score: 0
Accepted
time: 689ms
memory: 40732kb
input:
199995 00000110100111110000000011000001001001011111000011111011110101011011000010000000100000010101011000001010001010000011010111001000001001001000000100100100000100011100010110000001000101100001001000010000010010100000100100101010100010001000101000100010001101100101000110001000000000100011100000110...
output:
437571 434834 435183 436905 435323 434308 435305 434615 434876 435191 435242 434328 434035 434293 434268 437461 434921 434916 436581 434092 436788 435056 434432 436655 434461 437129 434268 436386 434099 436808 437038 436161 435446 438614 436574 437395 435020 438421 435350 438378 435912 435705 435919...
result:
ok 199995 numbers
Test #26:
score: 0
Accepted
time: 556ms
memory: 41396kb
input:
199999 11011000011111010011101110011111101011011101000011010011001010001101111110011001110111110111111011100110011110001100110011101111111101111110011110010010110010111110111111110111111110011011011100011011101011111101111111011011100000111110110110111111101101011111100000111111111111100011111110000...
output:
291439 291742 291442 292022 291998 292608 295175 293609 292799 293559 291204 292299 292807 291753 291592 291681 291789 291113 292605 291236 293687 292590 292121 291962 292701 291346 291450 291272 292838 292499 291828 292336 293447 291229 291197 293260 291994 292390 293090 292506 291904 293782 291937...
result:
ok 199999 numbers
Test #27:
score: 0
Accepted
time: 865ms
memory: 47784kb
input:
200000 00000011000000000100000000001000000001100000100100001000010001000000010000000011000000000000000010000000100000000100100000000000000000000000100000000000110001000011000000000010010000010000010000000000001100001000000010001000010101001011000000010000000010000110000000100100000011000100000000011...
output:
681455358 468197043 1070325733 948325724 469434574 681973264 622901817 465605711 527822442 536927474 465350493 965440987 1005777116 698587050 482170094 504375550 465714755 979934888 649132898 465535341 712528930 1068718453 466037967 551607704 997167874 491875920 559610578 466568379 537773929 4938158...
result:
ok 200000 numbers
Test #28:
score: 0
Accepted
time: 610ms
memory: 45124kb
input:
199998 11110000010110111000110111010001111011001101110000000010111101001001010101010101101010111010111001100000011111010111011001111111111111111110111111111111111101110110100100011100100100010001001011111001100111001110011110000110111101110010001100111011101100110011010011011010001011111011100101010...
output:
681719313 680943177 794903414 792840382 680920833 832084801 899229379 723681761 713907202 704143835 687194174 694486074 1102992021 1083116949 1131396698 885039246 708236132 1099042193 920218538 906795724 682479540 1023939873 812277257 994058145 681015878 745399876 680860371 800987705 1110259446 9583...
result:
ok 199998 numbers
Test #29:
score: 0
Accepted
time: 867ms
memory: 40184kb
input:
200000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
2060440 3004958 2251474 1637770 3515602 1490120 1261691 1517553 2898401 2596730 2080370 2491818 3198944 1149625 2931206 3685996 2670340 3221923 1932086 3668434 3630758 2161071 3451542 1430975 2767398 3198704 1144369 1387995 1137842 2955268 3281142 1909946 1285220 2466416 2154556 2102368 1932708 3159...
result:
ok 200000 numbers
Test #30:
score: 0
Accepted
time: 460ms
memory: 42864kb
input:
200000 01011010111111110111111111101111111111111111101101111111010111111111111110011101111111101111111111111111111111111011111110011111110110111111111111111111101111110111111111111110111111010111000011111101111111111111111101111111111111111110111111011111111111111111111111111111111111101111111110110...
output:
52769133 48827146 53366676 50519006 52424681 51787529 51920218 49059738 48794052 49070894 49259262 54031420 48684749 48785250 50070530 49574576 49414777 53514393 52738876 49147473 52569747 52936197 48796751 48572123 49173174 51788740 50517257 48582318 48568687 54529196 54795681 50932575 54817910 487...
result:
ok 200000 numbers
Test #31:
score: 0
Accepted
time: 687ms
memory: 39308kb
input:
199999 00001100010011010111110001000110110010000111110001110101001010000110011111001001100101110000011011000010101010001110011111110001101010100110000000010011000011110110010110001110011000001110010011101011010001110000000110100011100011000110100010001111000101000111001011000000011010110101001100011...
output:
47502957 47814769 48163322 46144105 45818641 45833999 46166717 48045900 46306696 45831258 47572851 45815816 47372109 47146916 47147608 47227904 46290694 46024693 45852748 47185762 48073486 46062217 47205680 46303101 45885562 46807872 46574971 48191288 46212253 46367014 47576148 46224770 48470277 469...
result:
ok 199999 numbers
Test #32:
score: 0
Accepted
time: 526ms
memory: 39752kb
input:
200000 11011001111111101111011011100111110111111101110111101111111111101110111100101111011110111111011111111110111110111011111111111010110101011101010110011110111101110101111110011011101111111111111111100011111111111111101011111111111011111110110001111111111111011111011111011011101110111011111101100...
output:
31515386 30801555 31082283 30801729 30794895 31263078 31433396 30860627 31414887 30797012 31128928 30850998 30966045 32100918 31475454 31223366 31025437 31684173 31584925 30917301 30919195 30793597 32175969 31271148 30795629 31079002 31344142 31458594 30842506 31808736 30949936 30815710 30818457 311...
result:
ok 200000 numbers
Test #33:
score: 0
Accepted
time: 885ms
memory: 40792kb
input:
200000 00000000000000000010000000000000000000000000000000000010000000000000000000000010000000000000000000000000000000000000000000000000000000000100000000000000001000000000000000000001000000000000000001000000000000000000000010000000000000000000000000000000000000000000000000100000010000010000000000000...
output:
1287859 1278710 1282256 1282660 1277644 1278063 1277768 1300070 1287876 1313288 1277552 1279407 1307067 1286140 1301451 1277789 1288478 1277993 1309631 1277717 1300626 1291718 1286010 1282351 1278741 1277474 1277964 1283193 1277702 1290000 1283696 1277520 1298581 1281070 1281157 1289063 1277565 1277...
result:
ok 200000 numbers
Test #34:
score: 0
Accepted
time: 636ms
memory: 40732kb
input:
200000 00001000110111001001011110111010001011000101011110101101111111010111011100011111000000110010110000010111110111111001110001010111100111000010000101110011110110000010001111100000100000101100101000001010110100111101000100011111001110011011011100010100011110101100110100010100111010011010110011110...
output:
4518403 4516821 4522737 4532732 4517570 4516679 4519567 4518266 4518951 4516705 4517645 4521426 4520926 4516496 4528280 4516534 4526112 4536472 4538716 4516947 4534679 4527791 4521201 4519319 4522799 4519063 4517109 4533127 4520978 4526661 4521806 4517414 4521381 4520317 4518667 4537712 4517043 4516...
result:
ok 200000 numbers
Test #35:
score: 0
Accepted
time: 663ms
memory: 39440kb
input:
200000 00001110101100111000000001111001010000010000110100100001001001101110001001000000001111000010111000000010100100010101101010101110110101111100000110001001101110011100100001011000001100111100111110110110010100001110001001111110101101001110101010010011011111001110010000001001000101010111011100111...
output:
240868 240876 240858 241049 240902 240842 240842 240881 240933 240944 241093 240854 240873 240907 240998 240880 240894 240914 240872 240971 240880 240990 240919 240941 240978 240857 240896 240860 240931 240906 240885 240942 240850 240942 240917 240987 240949 240877 240921 240853 240908 241002 240883...
result:
ok 200000 numbers
Test #36:
score: 0
Accepted
time: 403ms
memory: 40576kb
input:
199999 11111101111111111111111111111111111111111011111111111111111111111111111111111111111111111111111111111111111111111111111111110111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
output:
18803 18803 18803 18803 18803 18803 18846 18803 18803 18826 18803 18803 18803 18803 18803 18803 18803 18803 18803 18803 18803 18803 18803 18803 18803 18803 18836 18803 18839 18803 18803 18803 18803 18803 18803 18803 18803 18803 18831 18803 18803 18851 18803 18803 18803 18803 18803 18803 18803 18827 ...
result:
ok 199999 numbers
Test #37:
score: 0
Accepted
time: 325ms
memory: 36548kb
input:
200000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
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:
ok 200000 numbers
Test #38:
score: 0
Accepted
time: 613ms
memory: 40780kb
input:
200000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...
result:
ok 200000 numbers
Test #39:
score: 0
Accepted
time: 328ms
memory: 41124kb
input:
200000 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
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:
ok 200000 numbers
Test #40:
score: 0
Accepted
time: 618ms
memory: 39656kb
input:
200000 01101101011101001110101111100111101100100000000000001011101010111001001000000101101111001100111010100100111000001010100010011011101001010001011100001011110100000011000010010100011101101000001000011110111101110000101110010100110110000000000011000000000100110111000101010100101011100100001110100...
output:
3 1 1 3 1 1 3 1 3 1 1 1 3 1 3 3 1 1 1 3 1 3 1 1 1 1 1 3 3 1 1 1 1 3 1 1 3 3 1 3 3 3 3 3 3 3 3 3 3 3 3 3 1 3 1 1 1 3 1 3 1 3 1 1 1 3 3 1 3 3 1 3 3 3 3 3 3 1 3 1 1 3 1 1 1 1 3 3 1 1 3 3 1 1 1 3 1 3 1 3 3 1 3 3 1 1 1 3 3 3 3 3 1 3 1 3 1 3 3 3 1 3 3 1 1 3 1 1 1 3 1 3 3 1 3 1 3 3 3 1 3 1 1 1 3 3 3 3 1 3 ...
result:
ok 200000 numbers
Test #41:
score: 0
Accepted
time: 710ms
memory: 52172kb
input:
200000 10011000011001010001101000011100000101001101010110001111111001011110001011101000101000000110110000010110110001100101110100101100000101001011100110110111001111110010111110001100111011110111111011100111100000011110010001110010100110011000110101000010000110010110000100000101010111101011101100110...
output:
1641305406 2268611581 1224289755 1526756396 1797114739 1213760195 1906781059 1805506554 1686932768 1291176943 2024050022 2431148844 1357165318 1954650057 1879386096 1226540705 1976802657 2156028318 1845586674 1301681014 1316321771 2461112751 1788118540 1832791607 1846761913 1210964029 1361699375 219...
result:
ok 200000 numbers
Test #42:
score: 0
Accepted
time: 662ms
memory: 44392kb
input:
199997 10001001111100111011110001010111111110011111011110111100111010001000100010100111000110001111010011010101101111101100010100001100100100111011011000110001110111011010000101001011110011001010011100111101101000111111100000111011011110111011001010011110011010001001001111110001111100011111111011001...
output:
180264672 137429617 195527871 153074740 235352063 177053100 125472621 184394825 128321724 128918742 174811632 125870817 144894712 173383075 187160361 199139982 140057029 137436902 175519586 177577277 126517305 151725397 157910303 134791282 179289222 137953907 129024879 126778109 165196461 191433008 ...
result:
ok 199997 numbers
Test #43:
score: 0
Accepted
time: 617ms
memory: 39708kb
input:
200000 11101110111010000000011010110001100101101011100100000010010111101001011001001100100100010101001001011000101111111101001001100100011110000011000101010101110000010000010110111000111111110010110100111011101101100001000010110000011110101000100110100011101110101101110100101100100100001011011000010...
output:
4142223 4668287 4196808 4563175 3540569 4288502 4311799 3184511 3167896 3417637 4660834 3184563 4387352 3221506 4150800 4296015 3844133 3884510 3499640 4512781 5181416 3205517 4458993 4164491 3255078 3807371 3854352 4707220 4392960 4849794 3159900 4049316 4408933 3516532 4886905 3919076 3898209 4650...
result:
ok 200000 numbers
Test #44:
score: 0
Accepted
time: 706ms
memory: 43964kb
input:
200000 10111000101101100111100110010010000100101110010000000100000111111011111110001010110110000111111001000011000000000000101001101010101010001100101110100111000011001000011001010011000011111010110000011110111010111010011100101000001111100111111010011111000100001000001010101011011011010000001111010...
output:
485799975 718428751 474756882 710741507 479020542 491824787 604570827 529943255 500679508 592013358 732558904 476402543 536913819 679152659 570064219 476130975 534138031 506477657 513492119 483046808 498847603 752218744 498364241 646292547 491935411 541916711 804517539 793749577 653721240 489059693 ...
result:
ok 200000 numbers
Test #45:
score: 0
Accepted
time: 640ms
memory: 41372kb
input:
200000 01011111000111110110111100110000100000110000111110101101011010010101100011010010001110011011011000010101000000001100010001111100010111101000111110111010100000111011010110110101000111110110100000110010000000100000001111011001001111001010101001011011000100101001100011011101000110101101111000101...
output:
86403528 79148090 57100017 70915688 74703189 70085696 103962042 70479936 57736923 82752293 84704548 70803969 62356069 66075064 74727854 89401789 88023270 57984358 85225903 68282481 79590183 61412787 76421742 69294738 64788363 64746666 82541824 71411502 72187605 75324104 59585977 71453749 59585977 82...
result:
ok 200000 numbers
Test #46:
score: 0
Accepted
time: 629ms
memory: 40572kb
input:
199997 11001111000100111011010010101111010011111100111000100001010000110101000000000001010100101010000110010110111000000000100111100111011010100101111110011100111011010100111001101110100111010110010010000110101011000101011010110101110011101100011110100100000111001001001011010101100100010101011001011...
output:
1951862 2060339 2130581 2260839 1879062 1691253 2044833 2048134 1662230 2065437 2099023 2058403 2046234 1820284 2047900 2000260 1954515 1668642 2152934 2172217 2144778 1938346 2130323 1952407 2022639 2046499 2103470 2077435 1652573 2318842 1711062 2055501 1862427 2309727 1719703 1781155 1988705 1729...
result:
ok 199997 numbers
Test #47:
score: 0
Accepted
time: 722ms
memory: 45576kb
input:
200000 10011010101001101001110110110101001010101001101111100001110011101010101111101101101011110110011110100111111111011111001111011100111111001110100000101001110111011011101111011000101111100111010000100001101110111010111100010110110100010101000011000110000001100101100101101101101001001010001101000...
output:
287714553 356098078 340325369 263383250 267717772 269291658 291200403 240173932 263719565 342244607 247830092 290753804 266019975 248415867 251380931 273413726 280424411 288645573 287498873 242558579 277313200 274419642 302884782 240323519 265158800 234655732 221491581 231990183 357387430 283905263 ...
result:
ok 200000 numbers
Test #48:
score: 0
Accepted
time: 634ms
memory: 40144kb
input:
200000 00111101010111110101001111010111111010101111011101110011000011110110111010000101011111100111110101101001100011111001101101010101101100011110001100011001010000010001010110001010111110100101110100001000001001000110100100110000110011010000100101111000110000001110000101111100000101011000100010111...
output:
21246183 21847626 20447783 24114862 22462172 19138429 22115587 20060869 23103219 21611727 21892292 22614646 22824168 19573518 21677347 24498485 20854417 21979847 18775596 19717391 23546043 18795928 21157050 19210812 21323119 20646256 21986596 21029617 20674464 21409450 19696809 21616006 23993343 272...
result:
ok 200000 numbers
Test #49:
score: 0
Accepted
time: 595ms
memory: 38536kb
input:
199999 11011110001011000111010011011011101000001111111010100111000101011010011001011011110001111101010110101000110001001010010011101110100110010100011011101010101110001111001011101010101011100111110100010000000010110000110000001101101111101101011001011100100011110011010010010010100011100111110101011...
output:
870095 932693 881848 855528 912276 863512 847934 853026 881669 1031469 873397 1075454 848101 914949 893495 879265 880296 858763 868580 832422 915972 842575 890236 855175 849606 875182 857253 921944 853146 857275 845800 867683 903819 926271 865632 875148 998536 843586 906913 826422 869969 1032844 882...
result:
ok 199999 numbers
Test #50:
score: 0
Accepted
time: 713ms
memory: 60160kb
input:
200000 00101001111100010010001100111101111101010101100000110101000110001001111101001010011000100010011111111100000011010110101101000100111110000101111101111110111001110001000010011000110001110111101001000001100110010101100100110000011000101010101010110110000111110100110001100011101101101001001001000...
output:
3579466212 2846716232 3565307166 4540661536 3679948300 4745701220 4254719412 3153674624 4864606674 2500617812 5001574330 2928871852 4403815062 2500202240 2602057876 4513896678 4354398732 3620105470 3038401698 2576594020 2707730554 3101562736 4818229362 2500334488 4807579794 2504872026 2777931746 251...
result:
ok 200000 numbers
Extra Test:
score: 0
Extra Test Passed