QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#270209 | #7151. Tree embedding | ddl_VS_pigeon# | AC ✓ | 4ms | 4292kb | C++17 | 3.6kb | 2023-11-30 16:31:42 | 2023-11-30 16:31:43 |
Judging History
answer
#include <algorithm>
#include <array>
#include <functional>
#include <iostream>
#include <vector>
using namespace std;
struct Tree {
int n;
vector<vector<pair<int, int>>> e;
vector<int> sz, vis;
vector<pair<int, int>> fa;
vector<vector<int>> vec;
Tree(int _n)
: n(_n), e(n * 2 + 1), sz(n * 2 + 1), vis(n * 2 + 1), fa(n * 2 + 1), vec(n * 2 + 1) {
vector<vector<pair<int, int>>> ex(n + 1);
for (int i = 1; i < n; i++) {
int u, v, w;
cin >> u >> v >> w;
ex[u].emplace_back(v, w);
ex[v].emplace_back(u, w);
}
auto build = [&](auto self, int v, int fa) -> void {
int lst = v;
for (auto [u, c] : ex[v]) {
if (u != fa) {
self(self, u, v);
e[u].emplace_back(u + n, c);
e[u + n].emplace_back(u, c);
e[u + n].emplace_back(lst, 0);
e[lst].emplace_back(u + n, 0);
lst = u + n;
}
}
};
build(build, 1, 1);
}
int getsz(int v) {
vis[v] = true, sz[v] = 1;
for (auto [u, c] : e[v]) {
if (!vis[u]) {
sz[v] += getsz(u);
}
}
vis[v] = false;
return sz[v];
}
int getrt(int v, int tot) {
vis[v] = true;
int r = v;
for (auto [u, c] : e[v]) {
if (!vis[u]) {
fa[u] = {v, c};
if (min(tot - sz[u], sz[u]) > min(tot - sz[r], sz[r])) {
r = u;
}
int x = getrt(u, tot);
if (min(tot - sz[x], sz[x]) > min(tot - sz[r], sz[r])) {
r = x;
}
}
}
vis[v] = false;
return r;
}
void append(int v, int dep, int sgn) {
vis[v] = true;
vec[v].emplace_back(dep);
for (auto [u, c] : e[v]) {
if (!vis[u]) {
append(u, dep + c * sgn, sgn);
}
}
vis[v] = false;
}
void add(int v, int i, int d) {
vis[v] = true;
vec[v][i] += d;
for (auto [u, c] : e[v]) {
if (!vis[u]) {
add(u, i, d);
}
}
vis[v] = false;
}
void solve(int v) {
int tot = getsz(v);
if (tot == 1) {
return;
}
int r = getrt(v, tot);
int x = fa[r].first, y = r, c = fa[r].second;
vis[y] = true, solve(x), vis[y] = false;
vis[x] = true, solve(y), vis[x] = false;
if (vec[x].size() > vec[y].size()) {
swap(x, y);
}
vis[y] = true;
while (vec[x].size() < vec[y].size()) {
append(x, vec[y][vec[x].size()] + c, 0);
}
for (int i = 0; i < (int)vec[x].size(); i++) {
int d = vec[y][i] + c - vec[x][i];
add(x, i, d);
}
append(x, 0, -1), vis[y] = false;
vis[x] = true, append(y, c, 1);
vis[x] = false;
}
};
void solve() {
int n;
cin >> n;
Tree tr(n);
tr.solve(1);
cout << tr.vec[1].size() << '\n';
for (int i = 1; i <= n; i++) {
for (auto v : tr.vec[i]) {
cout << v << ' ';
}
cout << '\n';
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int T = 1;
while (T--) {
solve();
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3900kb
input:
2 1 2 2
output:
2 0 0 2 2
result:
ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
4 1 2 1 1 3 1 1 4 1
output:
3 0 0 0 1 -1 -1 1 -1 1 1 1 1
result:
ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
10 8 2 33305 2 6 69148 3 2 78693 5 9 4671 4 9 60174 7 2 53555 9 2 44205 1 5 51522 4 10 8094
output:
5 -11988 95727 56193 11988 -56193 0 0 0 0 44205 78693 -78693 78693 78693 122898 -15969 104379 0 -104379 -60174 39534 44205 4671 -39534 -4671 69148 0 -69148 69148 113353 53555 53555 53555 53555 97760 33305 -33305 0 -33305 77510 44205 44205 0 -44205 0 -7875 112473 0 -112473 -68268
result:
ok
Test #4:
score: 0
Accepted
time: 1ms
memory: 3700kb
input:
7 3 2 84583 1 2 99813 2 6 69523 4 2 85328 5 7 95654 5 4 79707
output:
4 65222 264848 14485 -99813 165035 165035 -85328 0 249618 80452 -169911 -84583 79707 79707 0 85328 0 0 79707 165035 234558 234558 -154851 -69523 95654 95654 175361 260689
result:
ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
7 3 1 81630 4 3 90999 7 5 34787 4 2 45864 6 4 22160 3 7 70320
output:
4 9369 218493 9369 -81630 45864 0 45864 136863 90999 136863 90999 0 0 45864 0 90999 55466 241970 196106 -105107 22160 45864 -22160 113159 20679 207183 161319 -70320
result:
ok
Test #6:
score: 0
Accepted
time: 1ms
memory: 3708kb
input:
9 5 9 52 7 9 97888 4 7 72858 1 6 71334 6 2 19443 8 2 31727 5 3 14365 2 7 75461
output:
5 121510 264178 192792 -15316 -90777 173401 173401 173349 75461 0 14365 14365 14417 112305 187766 170798 170798 97888 -72858 148319 0 0 52 97940 173401 192844 192844 192792 56018 -19443 97940 97940 97888 0 75461 205128 141674 205076 107188 -31727 52 52 0 97888 173349
result:
ok
Test #7:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
2 1 2 20340
output:
2 0 0 20340 20340
result:
ok
Test #8:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
2 2 1 51883
output:
2 0 0 51883 51883
result:
ok
Test #9:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
8 8 7 10751 3 4 95845 6 7 62471 6 2 19671 2 3 29382 2 5 10022 7 1 3280
output:
5 -46080 -59191 46080 49053 -65751 0 0 0 29382 19671 29382 29382 29382 0 49053 125227 125227 29382 -95845 144898 10022 10022 10022 39404 29693 19671 0 -19671 49053 0 -42800 -62471 42800 49053 -62471 -32049 -73222 32049 49053 -73222
result:
ok
Test #10:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
9 4 9 36917 1 6 23007 5 4 46177 8 7 54587 1 7 71340 2 1 56998 6 3 27648 4 1 33264
output:
5 23007 23007 0 0 0 80005 80005 -56998 0 -56998 27648 27648 50655 50655 50655 56271 -10257 33264 0 -33264 102448 35920 79441 0 -79441 0 0 23007 23007 23007 -48333 94347 0 -71340 71340 6254 148934 0 -125927 125927 93188 -47174 70181 0 -70181
result:
ok
Test #11:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
10 7 5 75030 7 6 72683 10 7 21009 1 10 98067 8 6 78011 2 6 37017 3 7 59811 7 9 75484 4 9 29913
output:
5 -43592 152542 119076 0 -119076 39818 112501 109700 -109700 109700 135295 135295 -59811 59811 59811 29913 29913 105397 105397 105397 150514 150514 -75030 0 -75030 2801 75484 72683 -72683 72683 75484 75484 0 0 0 80812 -2527 150694 -150694 150694 0 0 75484 75484 75484 54475 54475 21009 0 -21...
result:
ok
Test #12:
score: 0
Accepted
time: 0ms
memory: 3908kb
input:
9 6 4 45480 1 3 73208 8 5 48334 2 8 85607 9 3 26872 6 7 38398 6 8 56313 8 3 34234
output:
5 0 73208 73208 73208 107442 124581 119841 -85607 -34234 -85607 73208 0 0 0 34234 140767 -67559 101793 -34234 -101793 87308 82568 0 -82568 48334 95287 -22079 56313 -34234 -56313 133685 16319 94711 -34234 -94711 38974 34234 0 -34234 0 100080 0 -26872 26872 61106
result:
ok
Test #13:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
10 3 2 43219 1 2 36963 5 10 33305 6 9 69148 4 9 78693 2 9 4671 9 7 60174 10 9 53555 10 8 44205
output:
5 21263 119152 90518 41634 -41634 58226 82189 53555 4671 -4671 101445 82189 10336 47890 -47890 132248 86860 -25138 -78693 78693 33305 0 33305 86860 86860 122703 156008 53555 -69148 -69148 113729 26686 113729 -60174 60174 44205 33305 -44205 97760 97760 53555 86860 53555 0 0 0 33305 0 53555 5...
result:
ok
Test #14:
score: 0
Accepted
time: 1ms
memory: 3612kb
input:
10 6 7 99813 1 9 69523 3 6 85328 9 5 95654 2 10 79707 2 8 98694 6 2 81188 6 9 62924 4 6 13856
output:
5 74589 167494 150711 132447 -132447 0 79707 0 81188 81188 166516 160895 -4140 -85328 85328 95044 174751 95044 -13856 13856 239766 97971 -14466 158578 -158578 81188 160895 81188 0 0 181001 260708 81188 -99813 -99813 98694 79707 -98694 179882 179882 144112 97971 81188 62924 -62924 79707 0 79...
result:
ok
Test #15:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
10 1 2 90999 2 7 34787 2 6 45864 6 10 22160 6 4 70320 3 2 25420 2 9 2202 7 5 72292 8 7 40402
output:
5 -45135 159023 45864 -90999 -90999 45864 68024 45864 0 0 71284 42604 71284 -25420 25420 70320 22160 -70320 116184 116184 83369 -39055 83369 107079 -107079 0 22160 0 45864 45864 11077 33237 11077 34787 -34787 51479 33237 -29325 75189 -75189 48066 68024 43662 -2202 2202 22160 0 22160 68024 6...
result:
ok
Test #16:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
10 9 6 14889 9 10 52 5 9 97888 9 4 72858 9 7 71334 9 8 19443 9 1 31727 2 9 14365 9 3 75461
output:
5 -31727 31727 31727 31727 -31727 14365 -14365 14365 14365 14365 75461 75461 75461 75461 75461 72858 72858 0 -72858 72858 97888 97888 0 -97888 -97888 14889 0 -14889 14889 -14889 71334 -71334 0 -71334 71334 19443 0 -19443 19443 19443 0 0 0 0 0 52 -52 0 -52 -52
result:
ok
Test #17:
score: 0
Accepted
time: 0ms
memory: 3900kb
input:
10 10 6 6075 10 2 98020 10 1 58423 2 4 99364 10 7 37755 8 7 13465 9 10 52741 3 7 91030 2 5 2008
output:
5 39597 255807 156443 -58423 58423 0 99364 0 98020 98020 226805 250659 226805 0 -128785 99364 0 99364 197384 197384 2008 99364 -2008 100028 100028 104095 191309 91945 -6075 6075 135775 159629 135775 0 -37755 149240 146164 149240 0 -51220 150761 250125 45279 0 -52741 98020 197384 98020 0 0
result:
ok
Test #18:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
10 7 6 86861 5 2 30580 8 6 10447 10 2 25869 2 6 62961 1 2 16000 3 4 6458 2 3 399 3 9 4363
output:
5 -15601 16000 15601 0 -16000 399 0 -399 0 0 0 0 0 399 399 6458 -6458 6458 6857 6857 30979 -30580 -30979 0 -30580 -62562 0 62562 -62961 62961 24299 -86861 149423 -149822 149822 -52115 10447 73009 -73408 73408 4363 4363 4363 4762 4762 26268 25869 -26268 0 -25869
result:
ok
Test #19:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
10 10 3 10751 5 8 95845 1 10 62471 3 9 19671 8 4 29382 2 3 10022 7 1 3280 1 6 18279 10 8 30909
output:
5 -31562 62471 31562 0 -62471 30180 10022 -10136 -20773 20773 20158 0 -20158 -10751 10751 29382 29382 29382 60291 60291 95845 -95845 95845 126754 126754 -13283 80750 49841 0 -80750 -28282 59191 34842 0 -65751 0 0 0 30909 30909 39829 -19671 -487 -30422 30422 30909 0 -30909 0 0
result:
ok
Test #20:
score: 0
Accepted
time: 1ms
memory: 3556kb
input:
10 3 9 1937 9 6 36917 10 4 23007 5 8 46177 10 2 54587 10 6 71340 7 9 56998 8 1 27648 6 8 33264
output:
5 10428 -5616 -10428 0 -60912 54587 54587 54587 125927 125927 36360 -1937 -32486 -38854 38854 23007 -23007 23007 94347 94347 84253 -79441 -84253 0 -79441 71340 0 -71340 0 0 91421 56998 22575 -93915 93915 38076 -33264 -38076 0 -33264 34423 0 -34423 -36917 36917 0 0 0 71340 71340
result:
ok
Test #21:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
10 5 3 58531 5 8 2182 3 2 75030 7 4 72683 4 3 21009 4 1 98067 2 9 78011 2 10 37017 5 6 59811
output:
5 -44046 77058 44046 0 -119076 0 0 0 75030 75030 75030 0 -75030 0 0 54021 -21009 -54021 0 -21009 16499 0 -16499 -58531 58531 76310 59811 43312 -118342 118342 126704 -93692 -126704 0 -93692 18681 -2182 -14317 -60713 60713 78011 -78011 78011 153041 153041 37017 37017 37017 112047 112047
result:
ok
Test #22:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
10 2 6 42660 5 6 45480 9 1 73208 3 4 48334 1 7 85607 4 8 26872 4 10 38398 6 4 56313 4 1 34234
output:
5 90547 64739 56313 34234 -34234 42660 0 42660 98973 98973 104647 147307 56313 -48334 -48334 56313 98973 56313 0 0 45480 42660 -45480 101793 101793 0 42660 0 56313 56313 176154 64739 -29294 119841 -119841 83185 98973 29441 -26872 26872 163755 -8469 129521 107442 -107442 94711 60575 94711 -3...
result:
ok
Test #23:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
14 1 8 99172 5 14 84394 3 14 7875 8 11 46747 11 12 91464 1 10 41274 4 3 51473 12 9 99888 13 14 48591 6 3 42998 12 7 9735 2 11 62362 12 3 24208
output:
6 -78663 21226 54455 213175 32083 -237383 129618 229507 -153826 4894 32083 -153826 0 51473 0 0 7875 24208 51473 0 51473 51473 59348 75681 92269 -25046 92269 7875 -84394 116477 42998 51473 -42998 42998 50873 67206 -14473 85416 0 -33943 41818 9735 20509 120398 -44717 114003 32083 -138211 75680...
result:
ok
Test #24:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
20 12 17 9662 8 18 79403 9 12 39209 12 2 88815 12 4 65532 13 11 55258 15 17 57286 17 10 31472 2 19 39326 20 8 53686 17 5 16764 2 16 79545 12 13 50718 1 14 58728 2 6 50181 20 2 7766 14 11 12309 3 13 18809 14 7 953
output:
6 -204376 23596 -140606 164392 88198 -177013 61452 61452 7766 0 0 88815 -59272 -59272 -112958 19288 -19288 -69527 38169 38169 -15517 154347 -154347 65532 -937 -20261 -90711 62389 -115241 -26426 111633 11271 57947 -50181 50181 138996 -144695 -34179 -200287 106617 30423 -119238 0 0 53686 61452 ...
result:
ok
Test #25:
score: 0
Accepted
time: 1ms
memory: 3672kb
input:
30 3 5 28796 4 9 10034 22 12 89509 21 8 23277 10 2 3196 4 29 59345 6 20 11469 10 13 51654 10 4 71995 7 12 28072 3 23 52059 7 26 50022 4 6 93782 10 25 13380 16 3 23595 7 9 36250 9 15 83594 11 2 1106 18 24 24090 28 3 42510 27 28 96564 10 8 34047 2 19 97541 10 17 75663 10 3 40752 30 1 16408 24 7 93194 ...
output:
7 -209109 -38096 -55105 -125765 216497 66975 -138970 -73335 16174 -835 -95015 118279 -75191 -3196 -110891 60122 43113 -138963 118279 -31243 -40752 1856 91365 74356 -26216 46284 0 71995 -82095 31326 71909 -138963 89483 -2447 -69548 -91926 185147 168138 -26216 -47498 -93782 165777 28072 117581 2...
result:
ok
Test #26:
score: 0
Accepted
time: 1ms
memory: 3684kb
input:
40 18 39 61594 12 17 36186 37 33 1532 10 6 91806 23 20 60906 19 9 15159 13 38 22702 22 3 60048 28 21 62359 22 25 6011 26 35 43190 34 31 4138 30 12 49058 25 6 89047 31 19 43124 13 4 49436 25 26 41836 25 5 16956 26 14 45706 21 36 68537 12 15 55029 33 27 52251 33 26 88024 34 21 78287 12 32 65664 12 25 ...
output:
7 -15969 148805 186361 33695 147135 131183 -141228 190956 166382 153281 -173230 164712 148760 -158805 179296 34626 111192 -20436 -48130 56014 -66059 49436 49436 72138 156028 180602 184740 194785 142215 117641 62089 -37392 -11049 -27001 -16956 214306 100685 -43914 68611 -83140 -99092 -89047 148...
result:
ok
Test #27:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
54 16 26 45496 4 34 82464 15 6 98989 25 42 37516 48 10 11511 52 12 48230 47 34 75909 48 29 62311 53 6 31322 40 31 25243 42 37 43372 26 42 21924 16 5 49734 26 36 43349 47 9 73734 39 41 89591 14 44 22016 34 1 60743 42 49 26617 4 39 29014 34 7 61100 50 2 19720 34 2 64617 43 40 2358 4 8 39665 39 33 9226...
output:
8 69986 191472 38664 38664 60743 123906 0 -60743 66112 195346 99407 34790 -64617 127780 64617 64617 227858 227858 196536 250226 63163 -87656 150819 150819 213193 130729 16943 16943 82464 63163 -82464 82464 -2417 19601 -33739 57253 -111128 295777 0 -232614 31322 31322 0 0 99407 162570 99407 9940...
result:
ok
Test #28:
score: 0
Accepted
time: 1ms
memory: 3692kb
input:
67 54 2 27000 47 1 56096 16 62 95394 45 33 93374 14 31 20926 41 6 89398 54 24 54732 36 18 64923 58 22 72499 33 40 48515 4 65 42746 40 49 50954 33 4 30319 52 36 28368 65 5 14020 23 20 64887 48 27 91661 17 32 56902 26 3 48451 59 38 38248 17 40 27460 49 57 84654 51 60 42960 24 28 39849 52 58 8142 50 35...
output:
8 -833 149641 12969 48726 26137 -1214 -27600 -33038 -26470 97212 70973 139542 -85730 135507 -164321 164321 -22468 89413 40042 46007 -78122 103045 71221 -131859 32205 122041 46007 46007 -6901 -28814 0 0 -24561 150767 -10759 31987 21825 27952 -56766 56766 3391 93227 74821 74821 -35715 0 28814 288...
result:
ok
Test #29:
score: 0
Accepted
time: 1ms
memory: 3688kb
input:
73 52 70 80451 44 32 1449 6 14 82173 24 38 56605 49 4 83134 2 53 62244 70 16 68371 69 50 60868 39 67 42364 17 19 94331 60 11 94001 71 51 91350 56 21 12570 30 73 2299 23 58 71318 71 72 78176 73 4 917 4 33 70353 40 20 30654 1 36 24366 8 10 59530 58 25 14218 1 67 45255 36 12 68333 47 40 12406 61 11 837...
output:
8 -237035 63827 -41754 155457 -7877 -152048 48664 -130886 -121816 -26580 3398 126836 -131552 -168579 -75011 -40479 -7987 1647 124090 252492 122411 -382063 -295706 213484 -55746 70934 196452 86357 -243648 -16004 -70353 152575 -24035 -71231 24035 -71231 71231 158169 244526 326748 -58800 27980 -34...
result:
ok
Test #30:
score: 0
Accepted
time: 1ms
memory: 3668kb
input:
87 49 25 39368 24 2 71698 58 17 91578 30 86 33561 78 43 11951 15 8 34603 66 76 61167 83 8 22548 48 63 91658 8 51 13731 70 3 61233 9 29 72302 63 21 52219 53 72 43756 56 13 78626 13 65 23833 8 11 91619 8 84 84693 64 8 51042 85 6 7205 40 68 60611 42 16 39505 59 50 94034 17 9 31620 72 78 73852 61 52 429...
output:
8 60708 269842 220976 192675 178915 222163 -65435 -139462 83710 83710 159071 -227577 -61407 227577 -227577 328032 62885 62885 218799 190498 -50590 219986 -63258 -137285 149721 189253 192568 87868 -63978 170134 224700 -150673 70227 70227 22434 0 -22434 0 0 109129 -24026 -24026 116687 94253 71819...
result:
ok
Test #31:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
2 2 1 27833
output:
2 0 0 27833 27833
result:
ok
Test #32:
score: 0
Accepted
time: 1ms
memory: 3664kb
input:
81 7 79 7136 79 21 33814 76 73 11348 18 9 98679 19 21 80484 25 68 85491 67 3 73962 63 61 99432 42 5 25124 71 45 29653 59 20 15283 42 21 8926 59 38 74175 23 49 57772 22 8 58928 13 57 35851 26 19 60247 8 1 41995 36 45 4771 60 68 9248 56 4 19565 45 7 26690 34 63 89165 18 79 19662 7 47 2497 16 73 75362 ...
output:
8 -75982 149348 345288 227227 -236748 184938 167381 -244191 208902 132144 252202 238688 121714 -28466 -191081 -114271 117793 -40977 208777 291983 313175 -301827 296550 373360 40485 181825 228821 220574 -120281 68471 90044 -166854 218221 228775 265125 90379 7679 3669 -77046 67864 221046 125926 1...
result:
ok
Test #33:
score: 0
Accepted
time: 1ms
memory: 3940kb
input:
100 66 20 64331 71 93 56075 94 37 24424 22 86 23870 43 97 27051 14 51 1989 87 75 50829 58 16 63588 100 73 26141 90 52 14995 35 49 5213 86 12 47936 25 5 6213 26 87 51404 73 9 40063 37 72 57353 59 8 79465 7 4 11042 89 33 19830 100 51 63700 44 63 36365 25 63 78125 83 20 27081 73 40 90964 54 26 96279 3 ...
output:
9 122397 103296 -73309 -68058 -146370 5572 232796 -3159 -192299 123670 -132597 54472 89071 -132597 -89071 89201 132597 135756 18209 -59916 34073 59916 112198 162042 -74860 -3159 -115357 316991 109484 -267903 126536 48224 -189022 276204 -3159 -235707 6213 -6213 6213 84338 84338 127864 127994 8433...
result:
ok
Test #34:
score: 0
Accepted
time: 1ms
memory: 3704kb
input:
100 56 22 62377 58 55 65266 65 51 8075 82 30 63128 41 65 98262 63 75 73348 26 78 78308 69 73 83265 32 35 51859 75 66 18818 82 23 90696 42 79 31835 38 87 46601 74 40 62693 65 64 78114 56 75 89854 39 11 40514 40 9 81703 9 92 22171 72 73 22340 56 98 67781 62 85 42175 24 83 27835 5 42 51782 38 27 54236 ...
output:
9 -195650 24237 -28424 186366 272986 -386488 317462 0 -286427 -109669 -215587 37774 -241019 16371 130851 458691 -230912 230912 -143010 34259 -61020 133726 240390 -353892 350058 0 -253831 -149232 -176686 -45540 -176686 170658 -176686 266540 76625 76625 -65636 -93090 31085 -107032 240312 -93090 33...
result:
ok
Test #35:
score: 0
Accepted
time: 1ms
memory: 3708kb
input:
100 37 33 60423 81 66 7160 16 11 67535 1 39 78194 31 45 4065 20 66 44706 82 75 5786 32 97 78750 79 37 77577 69 1 88048 66 28 33075 13 94 72629 41 92 54285 17 1 73982 78 54 16165 10 88 22354 15 18 44666 12 84 11147 35 64 319 68 28 80980 28 57 31900 49 55 30418 15 30 38989 20 31 45304 13 99 12193 57 7...
output:
9 -272428 11915 -39013 19234 176092 56667 -105715 -148399 -183019 -145130 -36883 237 -68814 48794 -70631 -154513 -148399 -134221 -202213 -231441 114298 -176290 389089 96665 -537302 -396967 248568 208863 176782 82385 145892 325319 248388 -192862 333197 481596 -198528 -121213 84552 -302683 262696 ...
result:
ok
Test #36:
score: 0
Accepted
time: 1ms
memory: 3716kb
input:
100 62 53 23877 7 67 40543 67 71 83890 13 34 25964 67 2 75276 57 9 50657 63 37 33265 50 57 74236 4 62 70592 27 62 24574 67 54 10045 100 67 56527 74 67 94674 72 57 52568 87 62 86921 97 62 54855 1 67 48819 32 67 73295 67 5 78468 57 20 39621 54 55 96020 25 16 61764 85 52 15551 70 67 6122 57 63 2854 28 ...
output:
9 -18611 101934 -129861 212178 -20691 138646 26457 -227499 -124095 -45068 -22161 -103404 136902 103404 165103 0 -103404 0 129510 -46187 -178680 311480 -71174 189129 174578 -277982 -174578 9218 60525 -190302 -16376 157690 198293 -54286 49874 -153278 108676 -25353 -100212 290646 28128 11359 -3192 ...
result:
ok
Test #37:
score: 0
Accepted
time: 1ms
memory: 3708kb
input:
100 96 51 21924 11 98 49734 19 100 43349 96 29 73734 26 37 89591 91 84 22016 47 68 60743 75 10 26617 93 14 29014 89 60 61100 15 50 19720 78 85 64617 19 33 2358 53 22 39665 17 55 92268 92 86 63163 16 3 9867 83 51 2739 97 34 80808 63 64 98261 90 53 84331 50 26 50006 94 64 83601 3 90 23836 47 20 60811 ...
output:
9 -90722 54113 55316 -60208 -28071 29945 -88597 -103282 99186 -224660 28651 -46858 -79694 -47557 208831 -267483 -157520 -79700 -177359 91890 16381 -191793 -110796 96732 -155384 -157520 -32399 -81104 188145 112636 -239188 -207051 192987 -251639 -157520 -79794 -112591 140720 123563 -191675 -75976 ...
result:
ok
Test #38:
score: 0
Accepted
time: 1ms
memory: 3952kb
input:
100 29 77 44162 71 20 58925 60 11 27000 59 97 56096 48 31 95394 13 99 93374 16 62 20926 53 32 89398 3 85 54732 71 30 64923 9 80 72499 98 95 48515 73 54 42746 53 9 50954 61 2 30319 26 100 28368 77 56 14020 77 41 64887 13 33 91661 34 70 56902 99 91 48451 57 27 38248 61 81 27460 61 22 84654 23 60 42960...
output:
9 -167405 -85155 38397 213497 140158 129619 -169390 -440 -171778 32304 -2832 46790 70530 -31180 -70530 30319 32267 32707 -50359 -25737 -40649 96451 -86352 12573 -52344 -440 -54732 129208 -241674 138918 -31248 41247 30708 273057 -440 -270669 328715 -165501 25577 11835 94920 -366501 -124152 -440 -...
result:
ok
Test #39:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
100 52 70 74912 79 46 68115 62 97 19163 63 42 28058 56 42 66605 9 57 64733 52 13 48405 21 68 84883 45 37 80451 7 47 1449 13 71 82173 41 3 56605 12 61 83134 18 25 62244 85 33 68371 36 57 60868 1 6 42364 39 29 94331 13 10 94001 9 7 91350 69 13 12570 83 7 2299 40 34 71318 41 85 78176 94 25 917 86 73 70...
output:
9 243863 -80292 151185 -105104 253649 -66033 3816 -114438 114438 333968 1139 -123012 35228 178140 -139787 139787 347219 347219 188419 -189526 62481 -75394 267 22671 -84888 0 -138944 296779 -61566 119764 -18750 -86539 274155 -167266 -225750 225750 112857 -46096 -64549 -70908 37915 0 -106136 10129...
result:
ok
Test #40:
score: 0
Accepted
time: 1ms
memory: 3648kb
input:
100 62 55 72959 99 13 34202 93 51 35518 83 85 75828 21 46 72408 29 93 3388 74 96 75883 81 70 13073 44 73 6169 83 23 70679 74 39 59144 78 11 40503 60 79 90818 86 44 40829 32 84 6422 40 75 93369 15 59 79221 31 74 99583 59 7 72150 5 93 49991 12 7 43986 67 79 90541 86 58 39368 18 78 71698 44 17 91578 38...
output:
9 61935 63069 156541 50691 3955 172740 71358 0 -50691 -36655 -97875 251703 258580 11883 -64 -180796 -302845 302845 127955 -76758 80938 -329721 -19491 332532 495992 0 -373943 109519 -82507 944 -62129 35435 -19144 39878 0 -141193 162617 19154 62635 -49991 3255 172040 72058 0 -49991 170775 -108445...
result:
ok
Test #41:
score: 0
Accepted
time: 1ms
memory: 3708kb
input:
100 19 45 3709 39 70 43393 54 24 94977 49 71 90894 89 24 10915 73 76 42043 43 38 27554 32 78 46 25 73 99183 15 68 7205 33 63 77331 39 16 14001 30 51 31206 69 13 27927 26 96 1369 85 73 25869 73 53 83374 48 10 94435 46 65 74490 48 26 8631 40 20 40810 15 39 46079 36 51 15930 13 75 32516 13 4 49535 33 1...
output:
9 82641 229505 99605 131495 229505 2236 -158309 0 -73432 128438 54741 -148856 181510 128438 196859 -96528 -196859 196859 120396 120396 -9504 -52908 120396 0 -120396 146569 146569 4695 4695 -94375 0 -4695 -94375 94375 250448 250448 174100 162980 33080 249002 174100 68657 -311414 -155341 155341 5...
result:
ok
Test #42:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
100 14 9 45032 64 30 88516 29 61 62092 83 11 60471 97 84 32298 87 57 90134 81 26 5662 1 99 33404 15 34 83812 35 7 98313 36 32 92767 41 40 73666 72 49 45942 89 47 56014 15 54 93649 22 21 72090 8 88 7136 49 73 33814 83 90 11348 31 99 98679 9 1 80484 88 81 85491 9 37 73962 13 95 99432 93 40 25124 55 4 ...
output:
10 0 0 33404 33404 42330 33404 80484 0 286048 213958 -38079 16947 219763 42561 357941 134669 110047 -286048 -101265 173355 -70878 -15852 172666 5534 244984 22100 91788 -213958 72090 -74696 -142943 101251 170011 332655 409347 289342 -278333 -213958 72090 -358817 9207 122005 454295 212467 193535 -...
result:
ok
Test #43:
score: 0
Accepted
time: 2ms
memory: 3872kb
input:
694 147 589 63460 577 525 24867 168 48 46802 320 49 56053 387 45 50030 394 179 31066 25 137 52761 146 176 47924 156 69 97243 126 78 43246 299 286 98398 63 159 97810 313 340 80398 285 66 74961 471 290 91679 321 672 65088 346 145 22183 63 516 56245 262 479 75583 301 104 92046 678 270 62662 354 287 268...
output:
12 -159679 121017 317534 334357 327071 288180 482891 554728 -128343 12444 -404303 -404303 150824 124733 529428 57184 305724 214267 -107757 560555 -189880 -331542 277842 -410130 -40710 40710 40710 64906 0 -40710 0 53089 0 0 97336 97336 114537 195957 177209 217871 230839 -59477 144732 130462 336353...
result:
ok
Test #44:
score: 0
Accepted
time: 1ms
memory: 3760kb
input:
243 112 85 29656 158 90 90481 7 224 74519 234 203 84992 211 163 40562 23 207 2621 32 206 45866 139 137 88564 167 73 28471 233 118 33350 176 54 36866 232 227 54696 212 30 88043 208 192 47939 85 22 4388 203 189 54130 177 71 11667 93 6 57606 102 201 17140 149 28 62053 216 20 48661 145 158 32199 208 140...
output:
10 76793 320452 239815 127470 110563 111995 48992 174597 174597 -174597 55047 227803 79775 362741 162659 498463 498810 404785 -275221 -404785 55497 228253 -9599 255579 55497 391301 391648 297623 -168059 -297623 239475 227366 77445 206225 142541 207323 304604 210579 -81015 -210579 201375 74433 83...
result:
ok
Test #45:
score: 0
Accepted
time: 1ms
memory: 3872kb
input:
229 166 193 54447 108 132 97263 156 17 38984 110 43 31667 23 184 79564 108 111 67697 13 31 98378 86 74 74184 178 75 95633 213 19 77916 41 73 4856 216 76 87443 56 108 43031 187 107 39032 150 174 99980 168 195 47899 74 136 46680 82 196 32622 29 14 42559 27 158 93866 49 229 85484 99 61 27912 3 25 81994...
output:
10 293222 173345 -419609 164997 -36966 -140046 216080 -337327 135687 -262551 288715 32228 -424116 131142 -41473 1071 216080 -341834 140194 -267058 34783 -132770 -322952 422704 188554 255003 -188554 -74776 -370090 243226 190042 188711 -176719 176719 -221861 103470 293333 -74776 -218557 238661 339...
result:
ok
Test #46:
score: 0
Accepted
time: 0ms
memory: 3924kb
input:
135 18 110 50257 93 82 38644 88 87 83809 119 60 33528 28 100 98246 16 3 4218 22 10 82711 124 21 9452 48 128 9313 67 4 53331 64 79 47618 37 75 70473 32 113 21071 52 107 89692 3 60 71663 115 123 59213 49 61 47261 57 19 30547 46 50 32041 23 86 63669 131 32 61464 67 116 1076 57 61 14112 44 121 11326 16 ...
output:
9 -59333 32591 97607 390408 461164 351366 -390408 -271075 -356880 -25055 101885 -111562 67724 265420 -166650 127608 -193757 -161136 130567 130567 -40806 0 0 0 71663 105191 137812 194350 141019 -229044 210223 46015 64519 -210223 144074 -176695 -119903 -55009 -175077 -61806 222676 249214 416532 -4...
result:
ok
Test #47:
score: 0
Accepted
time: 2ms
memory: 4120kb
input:
683 235 104 98616 92 434 23280 474 273 65503 23 560 76232 399 625 51375 95 541 97791 294 464 23918 1 522 35198 90 4 40934 299 644 78673 470 391 33958 630 101 40872 50 323 70111 296 52 95959 3 523 50951 428 463 84150 257 401 65337 551 601 25697 512 668 12532 327 378 62008 386 449 57976 451 411 21345 ...
output:
12 -29204 36875 51453 -13428 411757 -98413 414554 346679 -100404 -349787 380035 -390784 -142675 -28176 98571 70185 -72628 -83739 -116447 116447 116447 225798 295362 306111 -69241 -56644 -84961 -26437 23994 -99873 -67085 0 -67085 144168 213732 224481 -13862 -51283 72320 187462 -37521 -5291 6475 37...
result:
ok
Test #48:
score: 0
Accepted
time: 2ms
memory: 3856kb
input:
668 60 628 90967 90 181 51755 225 381 51207 351 335 15056 315 299 97634 533 364 80940 27 328 8478 580 222 66561 131 514 68998 408 530 33026 481 46 19385 108 186 21688 16 262 36552 118 532 99424 135 553 10812 368 488 56555 232 515 96909 169 572 86653 653 365 17004 309 571 84879 558 552 3546 374 349 1...
output:
12 -131571 -57340 153820 -232488 120920 40675 278042 379946 189392 200374 313805 -301762 12973 25698 28689 199074 26131 104093 244920 379019 -47980 -185628 160673 148630 208399 110706 -37671 215894 211089 -274377 326130 230389 -277820 105080 241883 -229840 -17224 -14965 121530 282177 142423 -2115...
result:
ok
Test #49:
score: 0
Accepted
time: 2ms
memory: 4076kb
input:
654 253 300 46023 74 450 58055 70 278 34456 466 79 61503 260 552 86524 280 333 15911 392 584 27739 542 112 4504 34 615 67012 621 618 7667 371 82 49159 512 124 7194 233 431 83098 235 541 13140 195 151 71573 191 45 57933 487 20 32085 386 60 61203 423 650 25500 17 252 54298 450 478 15503 30 258 43193 4...
output:
12 -137740 310014 -82496 12531 4634 220460 420337 92368 -131662 -6527 -318618 -318618 -244959 -45757 21312 31665 -90670 114355 400078 20863 0 -209694 107975 -298359 -198272 -30638 42947 -156983 -142938 112552 10651 236080 0 -173157 107242 107242 -221676 -14630 -228705 127921 124910 190016 95693 1...
result:
ok
Test #50:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
560 53 332 14502 304 546 51673 536 85 76888 466 391 18058 82 469 83789 209 219 81545 30 430 16897 153 372 31499 93 62 26371 37 97 38332 30 187 22007 288 58 92087 298 34 41813 278 344 64464 82 150 3559 334 547 87083 390 453 91183 271 182 59777 32 323 50174 506 509 43522 176 504 23582 528 62 95406 483...
output:
12 -145778 810 -200387 -395749 62676 263391 315789 230757 0 -285635 318972 379652 43652 190240 -69312 -234061 85998 101703 29191 69069 0 -123947 157284 217964 -202581 40687 -21761 -413821 300287 162276 -248520 -239535 -313490 -125456 191274 -219473 -98215 206001 9156 -250074 226921 -39220 170114 ...
result:
ok
Test #51:
score: 0
Accepted
time: 0ms
memory: 3904kb
input:
546 206 298 75420 519 234 34209 303 439 91769 541 437 77447 220 441 66144 252 267 66928 427 429 59902 353 199 86893 74 145 4005 227 56 73170 543 33 54988 119 291 920 407 414 13805 516 124 55738 64 228 28358 415 166 96952 43 254 54136 445 132 94198 383 185 5931 197 462 65982 210 191 17224 122 352 918...
output:
12 255461 427633 -58433 -39424 509 -353171 -309753 329075 -315389 150153 -422392 -367217 285327 221784 -49865 -21001 109941 -258407 -169425 162963 138399 331702 31396 -276527 321117 22882 -40669 353774 170393 86209 327463 108163 -380728 -337578 337578 392753 226032 162489 212816 307926 -57012 130...
result:
ok
Test #52:
score: 0
Accepted
time: 3ms
memory: 4116kb
input:
763 384 629 2722 249 734 76525 750 364 69562 269 516 98782 582 366 79581 16 142 27573 263 43 13588 59 194 11024 212 64 73238 537 484 8035 252 459 98546 731 106 23446 416 552 2794 381 658 4901 213 544 64530 336 286 56704 395 169 27669 618 231 47977 693 211 69456 246 65 32408 338 109 76053 180 216 929...
output:
13 -47261 109535 -98149 114246 135000 -176499 124190 -160964 -124190 122760 -160964 257551 257551 -162919 133203 156385 -28829 70698 -137738 -138300 -141407 211090 60261 -146906 0 -243493 -190368 67240 225726 133809 -78975 61295 -127309 -57626 12057 60261 -63125 0 -159712 -120584 124506 352480 89...
result:
ok
Test #53:
score: 0
Accepted
time: 4ms
memory: 4288kb
input:
1000 572 527 49791 32 218 21645 179 931 16785 754 301 86556 672 38 96080 467 218 14665 428 774 53050 137 701 5302 388 302 17617 730 111 39815 846 797 27547 804 631 51043 606 548 72483 772 42 87127 767 396 14101 584 651 67827 391 898 45509 529 757 87851 822 6 24457 503 796 74359 529 835 61147 507 782...
output:
14 21454 311435 -24491 12952 -226505 -238455 -98035 16242 -545512 479924 -488183 762039 -88374 -531787 452103 430762 99336 -354411 -146908 -816998 20708 -524133 194847 960803 -261152 230252 -865300 776926 420162 302877 -198675 -129614 -426511 -729373 224175 -257098 398314 -936 -261152 230252 -7911...
result:
ok
Test #54:
score: 0
Accepted
time: 3ms
memory: 4224kb
input:
1000 481 332 23354 796 115 6792 367 308 46007 157 330 34563 717 189 44526 4 187 88056 862 216 76013 111 814 3711 457 772 76852 376 259 47169 786 571 72024 963 715 53630 753 74 80513 267 378 66504 901 493 41644 308 869 67462 749 281 26985 898 505 83442 560 988 84702 40 784 5179 81 874 57506 599 855 3...
output:
13 -675849 201580 -63734 124103 17846 -611896 -76588 -65189 520758 300074 153237 -170407 -349256 -140175 430304 350604 -108083 350539 -835533 -169653 -46337 103180 130188 277551 -643977 473570 -309208 -296819 -205904 -74700 205264 140051 -250616 -497053 -296871 -437444 388262 754688 925095 -66584...
result:
ok
Test #55:
score: 0
Accepted
time: 3ms
memory: 3992kb
input:
1000 145 580 53814 865 339 48835 274 748 18333 25 232 15274 556 862 92973 685 265 28743 117 479 23168 758 677 2119 467 479 3383 474 461 21820 19 846 92308 41 704 56217 901 897 45439 833 490 78586 379 630 93378 853 941 34393 553 624 43053 479 843 79034 141 847 69138 246 290 92896 94 365 62378 37 843 ...
output:
13 -206679 128134 173783 -11350 172332 305413 -181554 -282167 -69310 -236155 -286585 242506 -355270 -455468 -125769 -116330 -107201 286067 338624 -381513 -407925 191533 -532080 14243 734115 -815185 -91945 -126668 214065 19279 81076 527858 -411552 -311130 -24500 -426936 -442264 588966 -670036 -102...
result:
ok
Test #56:
score: 0
Accepted
time: 3ms
memory: 4288kb
input:
1000 526 58 51569 793 638 58173 402 205 47555 92 813 95985 977 807 8715 230 417 69430 983 72 46131 214 629 528 428 709 29914 752 765 29174 739 312 36785 58 56 26101 762 987 53469 141 447 57963 786 328 12408 624 985 58221 765 438 24528 560 444 74625 89 607 29383 922 450 91013 558 791 67249 482 582 63...
output:
13 -126457 317947 202750 -81745 386537 233046 -51537 -226929 93122 207728 1389342 0 -771405 375537 226845 -71494 -71851 449246 -398091 102805 -294213 254000 0 -215936 833873 833873 337942 87157 89613 282563 148580 -315549 468162 -563353 -733669 -27259 739411 -645196 645196 308000 -13347 94539 428...
result:
ok
Test #57:
score: 0
Accepted
time: 3ms
memory: 4008kb
input:
1000 310 311 49325 143 789 43320 622 205 76776 194 634 43992 790 203 81353 354 477 42821 752 888 25990 50 384 23128 116 918 80637 466 627 3825 203 96 13966 748 419 52880 443 11 85691 284 649 37340 355 165 7247 567 615 92448 376 216 73300 547 4 13321 898 19 46523 941 134 21833 327 119 72120 917 419 7...
output:
13 -1464 306195 -181070 -59904 -111052 -129993 296979 280260 384184 -174817 -134306 0 -237599 -32211 326170 -110373 -90651 -181749 -59296 266232 249513 384184 -144070 -103559 0 -206852 65658 409126 128954 -508331 52366 350441 -518311 591996 724847 168132 620964 -723847 723847 -86391 257077 98253 ...
result:
ok
Test #58:
score: 0
Accepted
time: 4ms
memory: 3988kb
input:
1000 940 310 47081 77 619 52659 444 641 49102 410 343 24703 211 70 29799 632 42 16212 327 108 16249 878 69 88833 122 981 39872 581 204 35371 687 399 34250 860 194 55467 878 574 93722 114 388 49422 78 221 91685 380 457 92083 133 941 78968 5 182 8913 984 572 74064 164 8 76846 638 941 76992 905 46 9540...
output:
13 -378542 -53254 104429 661316 151404 -263864 -366444 65924 153798 -663518 -569823 794745 -528831 -92838 43685 299845 445632 122020 230903 190646 -168899 91777 -190646 216567 261425 391547 -304558 -14393 284443 307350 198590 271092 -100600 -176540 145494 -134687 -120755 211689 144301 40257 64960...
result:
ok
Test #59:
score: 0
Accepted
time: 3ms
memory: 4288kb
input:
1000 108 997 44836 619 32 37806 927 40 78324 385 920 72711 439 640 45541 312 295 32707 81 664 63404 232 726 54538 852 892 66403 538 728 77318 779 372 46023 287 126 58055 103 8 34456 961 927 61503 887 327 86524 491 412 15911 310 116 27739 295 473 4504 770 711 67012 264 553 7667 833 443 49159 452 989 ...
output:
13 195442 -38396 55934 110370 330718 460767 337983 -124102 231240 -84257 -309637 0 -242962 128534 -167004 7254 -56192 774366 184342 -109169 -607506 -266580 69265 -249029 -254858 254858 310917 -36155 76277 -34327 563270 277122 226718 -267563 -60617 -208327 124070 219577 219577 345770 -181759 35456...
result:
ok
Test #60:
score: 0
Accepted
time: 3ms
memory: 3948kb
input:
1000 597 155 18400 957 263 79848 925 963 74842 909 282 20718 635 942 85475 486 717 73394 218 625 86367 922 614 52946 789 154 17126 988 664 84672 290 658 90499 910 126 60642 526 94 66678 44 168 40881 51 912 38258 657 27 82842 414 792 76511 247 799 96 361 15 51449 154 708 5784 193 736 78223 72 293 516...
output:
13 -284061 -85149 -142473 -5729 283833 145044 235659 59729 266460 163395 -393916 86518 -378598 61749 178191 146394 68818 71195 -95850 80597 -337847 -51188 23017 -49371 -364060 483762 -91837 161643 -73622 -3706 45201 160774 169287 70545 28056 23017 -49371 -160774 404518 321189 187804 -210791 -1337...
result:
ok
Test #61:
score: 0
Accepted
time: 4ms
memory: 4292kb
input:
1000 913 774 48859 357 308 89187 690 238 36768 481 612 1429 608 576 33921 596 376 46785 587 610 33522 880 450 75547 106 851 43657 632 552 59323 474 22 34976 566 967 63229 318 306 74708 196 648 52962 75 420 89992 587 701 82478 442 622 25283 80 369 95688 726 176 11693 557 761 93500 568 259 50390 851 6...
output:
13 81454 103876 224999 -29868 106445 -118588 -32515 646455 488709 -78873 -424851 663755 687703 377334 -109094 226029 150826 -487923 251002 31577 662139 -20927 -733220 780573 -23948 -541669 68721 68721 265957 29340 -139992 228493 -61220 512328 26948 -267319 314672 -23948 -75768 7203 178837 -145553...
result:
ok
Test #62:
score: 0
Accepted
time: 0ms
memory: 4056kb
input:
1000 464 300 12241 235 153 95587 674 581 76496 816 482 85201 257 852 75969 172 296 2281 541 492 92534 693 873 27794 788 311 89426 324 594 99692 340 2 94989 739 35 17608 781 197 5041 240 520 54475 762 786 8224 653 125 34640 395 104 74795 701 155 39491 548 156 55004 15 622 22118 759 672 50861 284 689 ...
output:
13 -1143402 324453 -32278 588775 -219261 -340336 346423 -3305 36418 725692 172023 -1155954 -825188 -225220 328211 -49260 -261837 524380 204219 245221 -250536 -214726 659250 343348 83934 -414700 70777 44807 -158221 435668 318800 43734 354842 288470 -382016 -241691 0 -355153 486241 -322926 -43845 -...
result:
ok
Extra Test:
score: 0
Extra Test Passed