QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#618540 | #943. Dynamic Diameter | tien_noob | 23.666667 | 481ms | 36544kb | C++14 | 6.6kb | 2024-10-06 23:26:50 | 2024-10-06 23:26:50 |
Judging History
answer
//Make CSP great again
//Vengeance
#include <bits/stdc++.h>
#define TASK "TESTCODE"
using namespace std;
const int N = 1e5;
int n, q;
long long w_mod;
vector<int> adj[N + 1];
int x[N], y[N];
int sz[N + 1], tin[N + 1], tout[N + 1];
int chain[N + 1], nchain, head[N + 1], par[N + 1], bc[N + 1];
long long d[N + 1], w[N];
int dfs_order[N + 1];
struct SegmentTree
{
long long tree[4 * N + 1], lazy[4 * N + 1];
SegmentTree()
{
memset(tree, -0x3f, sizeof(tree));
memset(lazy, 0, sizeof(lazy));
}
void push(int v)
{
long long val = lazy[v];
if (val == 0)
{
return ;
}
lazy[v] = 0;
tree[2 * v] += val;
lazy[2 * v] += val;
tree[2 * v + 1] += val;
lazy[2 * v + 1] += val;
}
void add(int v, int TreeL, int TreeR, int L, int R, long long val)
{
if (L > R)
{
return ;
}
if (TreeL == L && TreeR == R)
{
tree[v] += val;
lazy[v] += val;
return ;
}
push(v);
int mid = (TreeL + TreeR)/2;
add(v * 2, TreeL, mid, L, min(R, mid), val);
add(v * 2 + 1, mid + 1, TreeR, max(L, mid + 1), R, val);
tree[v] = max(tree[2 * v], tree[2 * v + 1]);
}
void add(int L, int R, long long val)
{
add(1, 1, n, L, R, val);
}
long long get(int v, int TreeL, int TreeR, int L, int R)
{
if (L > R)
{
return -1e18;
}
if (TreeL == L && TreeR == R)
{
return tree[v];
}
push(v);
int mid = (TreeL + TreeR)/2;
return max(get(v * 2, TreeL, mid, L, min(R, mid)), get(v * 2 + 1, mid + 1, TreeR, max(L, mid + 1), R));
}
long long get(int L, int R)
{
return get(1, 1, n, L, R);
}
void upd(int v, int TreeL, int TreeR, int pos, long long val)
{
if (TreeL == TreeR)
{
tree[v] = val;
lazy[v] = 0;
return ;
}
int mid = (TreeL + TreeR)/2;
push(v);
if (pos <= mid)
{
upd(v * 2, TreeL, mid, pos, val);
}
else
{
upd(v * 2 + 1, mid + 1, TreeR, pos, val);
}
tree[v] = max(tree[2 * v], tree[2 * v + 1]);
}
void upd(int pos, long long val)
{
upd(1, 1, n, pos, val);
}
int find_max()
{
int v = 1, L = 1, R = n;
while(true)
{
if (L == R)
{
return L;
}
int mid = (L + R)/2;
push(v);
if (tree[2 * v] > tree[2 * v + 1])
{
v = v * 2;
R = mid;
}
else
{
v = v * 2 + 1;
L = mid + 1;
}
}
}
} get_max_d, get_max_hld;
void preDFS(int u, int p)
{
sz[u] = 1;
for (int i : adj[u])
{
int v = x[i] ^ y[i] ^ u;
if (v == p)
{
continue;
}
d[v] = d[u] + w[i];
preDFS(v, u);
sz[u] += sz[v];
}
}
void buildHLD(int u, int p)
{
int bigchild = -1;
static int timer = 0;
tin[u] = ++timer;
dfs_order[timer] = u;
chain[u] = nchain;
if (head[nchain] == 0)
{
head[nchain] = u;
}
for (int i : adj[u])
{
int v = x[i] ^ y[i] ^ u;
if (v == p)
{
continue;
}
if (x[i] == v)
{
swap(x[i], y[i]);
}
if (bigchild == - 1 || sz[v] > sz[bigchild])
{
bigchild = v;
}
}
bc[u] = bigchild;
if (bigchild != -1)
{
par[bigchild] = u;
buildHLD(bigchild, u);
}
for (int i : adj[u])
{
int v = x[i] ^ y[i] ^ u;
if (v == p || v == bigchild)
{
continue;
}
++nchain;
par[v] = u;
buildHLD(v, u);
}
tout[u] = timer;
get_max_d.upd(tin[u], d[u]);
}
long long cal(int u, int except)
{
long long d_u = get_max_d.get(tin[u], tin[u]);
long long d_other = d_u;
if (except != -1)
{
d_other = max(d_other, get_max_d.get(tout[except] + 1, tout[u]));
d_other = max(d_other, get_max_d.get(tin[u], tin[except] - 1));
}
return d_other - 2 * d_u;
}
long long query()
{
long long res = 0;
int p = get_max_d.find_max();
p = dfs_order[p];
int u = p;
long long d_u = get_max_d.get(tin[u], tin[u]);
while(p != 0)
{
int h = head[chain[p]];
if (p != h)
{
res = max(res, d_u + get_max_hld.get(tin[h], tin[par[p]]));
}
p = par[h];
if (p != 0)
{
res = max(res, d_u + cal(p, h));
}
}
/*while(u != 1)
{
int p = par[u];
res = max(res, cal(p, u) + d_u);
u = p;
}*/
return res;
}
void upd(int i, long long nw_w)
{
int u = y[i];
long long dif = nw_w - w[i];
w[i] = nw_w;
get_max_d.add(tin[u], tout[u], dif);
get_max_hld.upd(tin[u], cal(u, bc[u]));
while(true)
{
int h = head[chain[u]];
int p = par[h];
if (p == 0)
{
break;
}
get_max_hld.upd(tin[p], cal(p, bc[p]));
u = p;
}
}
void read()
{
cin >> n >> q >> w_mod;
for (int i = 1; i < n; ++ i)
{
int u, v;
cin >> u >> v >> w[i];
x[i] = u;
y[i] = v;
adj[u].push_back(i);
adj[v].push_back(i);
}
}
void solve()
{
preDFS(1, 0);
buildHLD(1, 0);
for (int u = 1; u <= n; ++ u)
{
get_max_hld.upd(tin[u], cal(u, bc[u]));
}
long long last = 0;
while(q--)
{
long long i, e;
cin >> i >> e;
i = (i + last) % (n - 1);
++i;
e = (e + last) % w_mod;
upd(i, e);
last = query();
cout << last << '\n';
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
if (fopen(TASK".INP", "r"))
{
freopen(TASK".INP", "r", stdin);
//freopen(TASK".OUT", "w", stdout);
}
int t = 1;
bool typetest = false;
if (typetest)
{
cin >> t;
}
for (int __ = 1; __ <= t; ++ __)
{
//cout << "Case " << __ << ": ";
read();
solve();
}
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 22000kb
input:
10 100 10000 3 4 115 4 7 2757 1 5 5809 8 5 1111 6 2 7043 6 5 4932 6 4 4171 9 5 8499 10 5 2395 1 3517 8 7196 1 8064 6 7437 6 2421 8 67 7 6695 3 1217 1 920 1 1786 4 2541 5 266 4 6167 0 7590 6 195 8 4087 2 8073 6 8065 5 2882 2 3292 4 3435 6 8447 8 3419 0 9545 1 7922 0 4088 8 2546 4 7071 1 722 6 9178 0 ...
output:
21119 21746 23057 18619 18309 18309 19479 18309 19533 18309 18186 18262 19939 21768 20410 22382 20410 21356 17833 17119 13244 7187 4529 6469 8465 8524 9139 10958 11513 9377 9567 8338 8034 5923 5027 2900 2285 2068 1882 1945 2775 4745 4710 5813 7516 5813 4710 5561 6651 8019 9192 9658 8822 7818 5647 53...
result:
wrong answer 91st lines differ - expected: '3434', found: '3711'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 7
Accepted
Test #27:
score: 7
Accepted
time: 0ms
memory: 21944kb
input:
20 20 10000 1 2 835 1 3 57 1 4 1883 1 5 1349 1 6 1543 1 7 688 1 8 272 1 9 744 1 10 569 1 11 1019 1 12 201 1 13 1228 1 14 1194 1 15 1123 1 16 48 1 17 164 1 18 893 1 19 963 1 20 818 6 1 0 7412 10 6575 15 6696 0 7412 4 8318 18 7563 15 7502 1 7668 13 7859 14 8045 2 7969 12 8159 11 8040 2 8168 12 8192 0 ...
output:
3426 3426 3426 2892 2577 2577 2543 2472 2142 2142 2086 2018 1961 1961 1958 1653 1562 1432 1432 1064
result:
ok 20 lines
Test #28:
score: 7
Accepted
time: 0ms
memory: 21884kb
input:
20 200 10000 1 2 17 1 3 373 1 4 255 1 5 1243 1 6 468 1 7 1594 1 8 1375 1 9 383 1 10 36 1 11 1961 1 12 1816 1 13 1744 1 14 1611 1 15 1619 1 16 1620 1 17 144 1 18 1444 1 19 1129 1 20 1812 12 1 14 6239 16 6351 13 6228 17 6447 15 6815 10 6637 9 6762 4 6885 9 7217 18 7229 14 7381 8 7459 1 8746 18 9031 7 ...
output:
3777 3773 3773 3773 3556 3364 3239 3239 3064 2819 2687 2573 1597 1597 1757 1757 1096 851 756 776 776 776 1339 1339 776 759 759 746 746 746 624 501 416 364 805 364 270 189 112 111 107 107 1021 1620 1620 1190 360 191 121 107 103 78 172 77 588 791 588 948 509 166 729 863 1314 863 1228 863 863 774 762 7...
result:
ok 200 lines
Test #29:
score: 7
Accepted
time: 0ms
memory: 23920kb
input:
20 2000 10000 1 2 25 1 3 1900 1 4 1586 1 5 1319 1 6 219 1 7 1300 1 8 776 1 9 1051 1 10 362 1 11 1085 1 12 600 1 13 1576 1 14 315 1 15 1292 1 16 1167 1 17 1518 1 18 1911 1 19 1196 1 20 465 12 56 9 6271 1 6684 1 6622 6 6572 1 7038 3 6816 16 6979 4 8313 15 7409 5 7409 17 7710 10 7663 4 7957 17 7865 1 8...
output:
3811 3497 3487 3429 3230 3230 3211 2592 2592 2592 2496 2363 2252 2136 2136 1956 1505 1505 1267 1263 1173 1114 1630 934 1490 974 971 955 1421 955 378 470 470 728 470 378 371 1027 1190 543 534 301 301 292 290 1074 290 272 168 168 164 216 201 356 201 115 236 648 762 1241 1241 1206 1065 1500 1021 1249 8...
result:
ok 2000 lines
Test #30:
score: 7
Accepted
time: 8ms
memory: 24008kb
input:
20 20000 10000 1 2 1046 1 3 272 1 4 584 1 5 244 1 6 1124 1 7 1107 1 8 223 1 9 326 1 10 1816 1 11 891 1 12 1116 1 13 889 1 14 811 1 15 1377 1 16 636 1 17 69 1 18 1885 1 19 894 1 20 1613 2 267 12 6321 10 6503 10 6526 16 6628 14 6876 0 6939 14 7067 9 7348 6 7819 10 7891 11 7848 18 7848 1 8246 15 8316 9...
output:
3701 3498 3498 3498 3262 3262 3009 3009 2240 2223 2153 2153 1937 1780 1525 1246 1215 1527 910 882 861 424 869 869 1434 1011 424 547 547 525 691 525 384 361 286 240 477 465 210 192 186 368 1084 391 1184 1031 1374 652 309 555 484 1072 1487 1532 1597 1532 1532 1532 1487 1349 1007 913 415 413 390 215 17...
result:
ok 20000 lines
Test #31:
score: 7
Accepted
time: 42ms
memory: 22004kb
input:
20 100000 10000 1 2 499 1 3 916 1 4 1568 1 5 1135 1 6 136 1 7 1364 1 8 444 1 9 561 1 10 698 1 11 456 1 12 1543 1 13 1678 1 14 734 1 15 393 1 16 1768 1 17 1892 1 18 366 1 19 37 1 20 1051 6 354 11 6803 2 6437 6 6540 17 6688 5 6755 0 6860 11 7064 3 6998 2 7250 6 7399 1 7467 4 8496 13 9106 5 8569 2 8768...
output:
3660 3660 3570 3570 3246 3221 3042 3042 2813 2729 2594 1650 1432 1432 1259 1236 1197 1154 1064 1535 1203 1395 1203 1488 1488 1017 1132 1132 1017 1017 957 564 434 238 470 1110 1115 689 689 689 674 1180 1180 674 634 435 251 686 725 686 251 693 251 602 597 596 782 1242 1559 1265 782 1362 1420 1362 1362...
result:
ok 100000 lines
Test #32:
score: 7
Accepted
time: 5ms
memory: 21956kb
input:
2 10 10000 1 2 771 0 151 0 9855 0 9999 0 8476 0 1455 0 7763 0 3304 0 8286 0 2481 0 8467
output:
151 6 5 8481 9936 7699 1003 9289 1770 237
result:
ok 10 lines
Test #33:
score: 7
Accepted
time: 5ms
memory: 22028kb
input:
501 20 10000 1 2 1672 1 3 802 1 4 330 1 5 1394 1 6 1676 1 7 1751 1 8 417 1 9 1447 1 10 1736 1 11 956 1 12 224 1 13 203 1 14 1999 1 15 1385 1 16 1983 1 17 601 1 18 1800 1 19 1273 1 20 212 1 21 798 1 22 1535 1 23 669 1 24 1102 1 25 1117 1 26 563 1 27 1833 1 28 862 1 29 1243 1 30 1366 1 31 854 1 32 156...
output:
3989 3987 3986 3986 3986 3979 3979 3979 3974 3974 3968 3966 3966 3960 3954 3954 3952 3952 3952 3952
result:
ok 20 lines
Test #34:
score: 7
Accepted
time: 0ms
memory: 23980kb
input:
501 200 10000 1 2 392 1 3 9 1 4 1790 1 5 1700 1 6 321 1 7 1602 1 8 838 1 9 1217 1 10 1210 1 11 925 1 12 746 1 13 592 1 14 104 1 15 1647 1 16 1370 1 17 1827 1 18 709 1 19 1300 1 20 1659 1 21 590 1 22 1953 1 23 941 1 24 1653 1 25 1307 1 26 526 1 27 237 1 28 69 1 29 1993 1 30 947 1 31 396 1 32 1740 1 3...
output:
3989 3985 3985 3985 3985 3985 3980 3973 3973 3973 3970 3965 3965 3962 3948 3942 3942 3942 3942 3942 3936 3933 3933 3933 3924 3924 3924 3913 3887 3887 3887 3863 3863 3856 3856 3856 3855 3848 3848 3848 3848 3848 3845 3844 3844 3840 3840 3839 3839 3825 3821 3821 3811 3803 3803 3803 3802 3802 3796 3788 ...
result:
ok 200 lines
Test #35:
score: 7
Accepted
time: 5ms
memory: 21908kb
input:
501 2000 10000 1 2 178 1 3 1051 1 4 1631 1 5 1451 1 6 1282 1 7 1444 1 8 583 1 9 1321 1 10 1706 1 11 1108 1 12 279 1 13 573 1 14 1873 1 15 1931 1 16 1092 1 17 234 1 18 221 1 19 398 1 20 808 1 21 551 1 22 1274 1 23 982 1 24 242 1 25 1040 1 26 1018 1 27 577 1 28 451 1 29 1172 1 30 1088 1 31 1328 1 32 3...
output:
3981 3969 3968 3968 3967 3967 3964 3959 3956 3956 3951 3945 3945 3944 3938 3938 3935 3935 3931 3931 3931 3920 3920 3920 3920 3920 3910 3903 3903 3903 3903 3903 3899 3899 3893 3893 3893 3893 3893 3883 3883 3876 3875 3860 3860 3858 3858 3858 3857 3857 3857 3851 3841 3841 3838 3838 3829 3829 3829 3829 ...
result:
ok 2000 lines
Test #36:
score: 7
Accepted
time: 10ms
memory: 21984kb
input:
501 20000 10000 1 2 1385 1 3 510 1 4 1745 1 5 97 1 6 1133 1 7 1866 1 8 1058 1 9 1499 1 10 779 1 11 1822 1 12 476 1 13 1190 1 14 839 1 15 422 1 16 1534 1 17 39 1 18 56 1 19 37 1 20 1304 1 21 1161 1 22 1547 1 23 1533 1 24 1729 1 25 108 1 26 718 1 27 1784 1 28 1201 1 29 241 1 30 438 1 31 995 1 32 712 1...
output:
3994 3994 3991 3991 3991 3991 3991 3991 3986 3974 3974 3958 3958 3957 3957 3949 3949 3941 3939 3921 3921 3921 3921 3921 3906 3906 3903 3892 3887 3885 3885 3881 3881 3880 3880 3880 3880 3878 3878 3878 3873 3868 3868 3858 3841 3841 3841 3841 3837 3837 3832 3832 3832 3832 3813 3802 3802 3802 3802 3802 ...
result:
ok 20000 lines
Test #37:
score: 7
Accepted
time: 68ms
memory: 24008kb
input:
501 100000 10000 1 2 1459 1 3 960 1 4 1508 1 5 198 1 6 793 1 7 1364 1 8 1610 1 9 1201 1 10 721 1 11 840 1 12 539 1 13 1236 1 14 861 1 15 830 1 16 484 1 17 1610 1 18 272 1 19 381 1 20 1074 1 21 1921 1 22 1571 1 23 1709 1 24 408 1 25 1183 1 26 1380 1 27 1644 1 28 813 1 29 1498 1 30 1426 1 31 1276 1 32...
output:
3981 3981 3981 3981 3980 3961 3961 3959 3959 3957 3931 3931 3915 3910 3910 3910 3910 3908 3900 3900 3890 3889 3889 3882 3882 3882 3874 3874 3874 3874 3871 3868 3864 3861 3861 3855 3855 3854 3854 3854 3814 3814 3814 3814 3814 3808 3808 3808 3808 3794 3794 3779 3779 3748 3739 3739 3739 3737 3737 3737 ...
result:
ok 100000 lines
Test #38:
score: 7
Accepted
time: 3ms
memory: 22208kb
input:
5001 20 10000 1 2 1023 1 3 898 1 4 297 1 5 1041 1 6 145 1 7 543 1 8 111 1 9 1645 1 10 514 1 11 1671 1 12 1635 1 13 210 1 14 1820 1 15 311 1 16 811 1 17 373 1 18 1842 1 19 770 1 20 1106 1 21 418 1 22 168 1 23 524 1 24 950 1 25 1642 1 26 37 1 27 528 1 28 986 1 29 464 1 30 1448 1 31 364 1 32 982 1 33 1...
output:
4000 4000 3999 6886 6886 6886 6885 8630 5743 5742 3996 3996 3995 3994 3994 3994 5968 7835 5968 5968
result:
ok 20 lines
Test #39:
score: 7
Accepted
time: 0ms
memory: 22204kb
input:
5001 200 10000 1 2 1629 1 3 834 1 4 803 1 5 1119 1 6 1292 1 7 414 1 8 203 1 9 445 1 10 1644 1 11 1982 1 12 681 1 13 124 1 14 1135 1 15 671 1 16 64 1 17 1215 1 18 1594 1 19 1606 1 20 1545 1 21 314 1 22 1257 1 23 793 1 24 928 1 25 870 1 26 58 1 27 948 1 28 916 1 29 1937 1 30 126 1 31 1798 1 32 459 1 3...
output:
4000 4000 4000 4000 3999 3999 4182 3999 4033 5585 6502 4983 4033 4032 4032 3998 5276 5276 3998 5473 5473 5473 7954 6479 8685 6204 6203 6203 6203 6203 6203 7512 6203 8189 8189 6244 6203 7265 7265 7265 5058 5787 5787 4725 4725 4729 4725 5018 4725 4724 5148 4724 4723 4723 4723 3992 3991 4606 3991 3990 ...
result:
ok 200 lines
Test #40:
score: 7
Accepted
time: 3ms
memory: 22240kb
input:
5001 2000 10000 1 2 275 1 3 314 1 4 1278 1 5 1729 1 6 265 1 7 1139 1 8 782 1 9 291 1 10 821 1 11 518 1 12 93 1 13 202 1 14 1503 1 15 55 1 16 80 1 17 468 1 18 1525 1 19 1995 1 20 428 1 21 1376 1 22 426 1 23 830 1 24 255 1 25 1619 1 26 1009 1 27 702 1 28 376 1 29 150 1 30 1894 1 31 749 1 32 362 1 33 7...
output:
3999 3999 3999 3999 3999 3998 4952 4952 4952 4952 3998 5459 5800 6962 5842 5501 5501 3998 3998 3997 3997 3997 3996 3996 4685 4685 5240 5806 7048 5806 5240 6345 6211 4551 4734 4179 3996 4808 4808 4836 4836 4836 4836 4024 4024 6047 6047 6019 7327 7927 7212 5304 5302 5301 5301 6295 6295 6604 6604 7811 ...
result:
ok 2000 lines
Test #41:
score: 7
Accepted
time: 18ms
memory: 24164kb
input:
5001 20000 10000 1 2 1506 1 3 820 1 4 1164 1 5 1068 1 6 1945 1 7 527 1 8 1773 1 9 717 1 10 1836 1 11 1756 1 12 1304 1 13 221 1 14 1863 1 15 1820 1 16 410 1 17 220 1 18 554 1 19 1731 1 20 1028 1 21 465 1 22 695 1 23 1512 1 24 1995 1 25 343 1 26 1429 1 27 1335 1 28 1657 1 29 635 1 30 1328 1 31 226 1 3...
output:
4000 4000 4480 4480 4000 4000 4000 4000 4000 4000 5905 5905 4000 5035 6755 5035 4000 5785 4000 5504 6433 5504 6345 4841 5511 5511 6223 6223 6052 7200 7200 7200 6052 6052 7089 6052 6052 6346 5634 5038 4462 4450 4368 5908 5540 4000 4000 6635 8528 6635 6635 6635 3999 3998 3998 3997 3994 3992 3992 4716 ...
result:
ok 20000 lines
Test #42:
score: 7
Accepted
time: 91ms
memory: 22232kb
input:
5001 100000 10000 1 2 210 1 3 415 1 4 1274 1 5 989 1 6 1975 1 7 858 1 8 1684 1 9 1212 1 10 132 1 11 1950 1 12 1465 1 13 163 1 14 1689 1 15 602 1 16 718 1 17 402 1 18 461 1 19 1 1 20 1707 1 21 1777 1 22 715 1 23 426 1 24 1883 1 25 1174 1 26 16 1 27 161 1 28 1087 1 29 112 1 30 143 1 31 1317 1 32 1771 ...
output:
3999 4562 4671 5301 4848 6379 4848 4109 4538 4429 4429 3999 3997 5555 5554 8282 8282 5554 3996 3995 3995 3994 3994 3994 4795 4795 3993 3993 3993 3992 3992 3992 3991 3990 4192 4192 4192 4192 4192 4192 3990 4928 3990 4723 4723 4723 3990 3990 6056 3990 3990 7335 3990 3989 3989 3987 3986 3986 5168 5168 ...
result:
ok 100000 lines
Test #43:
score: 7
Accepted
time: 33ms
memory: 27048kb
input:
100000 20 10000 1 2 64 1 3 833 1 4 935 1 5 238 1 6 1902 1 7 321 1 8 1492 1 9 195 1 10 318 1 11 1579 1 12 897 1 13 840 1 14 896 1 15 1029 1 16 1747 1 17 1271 1 18 1977 1 19 1448 1 20 320 1 21 10 1 22 611 1 23 1765 1 24 275 1 25 818 1 26 1258 1 27 1724 1 28 172 1 29 1459 1 30 1792 1 31 547 1 32 558 1 ...
output:
4000 7977 7977 7977 7977 7977 4000 4000 4000 4000 11831 16066 8235 4000 4000 4000 4000 4000 4000 10747
result:
ok 20 lines
Test #44:
score: 7
Accepted
time: 38ms
memory: 27120kb
input:
100000 200 10000 1 2 1430 1 3 1072 1 4 1432 1 5 227 1 6 1304 1 7 1243 1 8 377 1 9 693 1 10 215 1 11 759 1 12 1287 1 13 1173 1 14 1679 1 15 883 1 16 1719 1 17 716 1 18 1489 1 19 785 1 20 70 1 21 1844 1 22 801 1 23 646 1 24 1601 1 25 925 1 26 585 1 27 187 1 28 1947 1 29 1052 1 30 165 1 31 1998 1 32 41...
output:
4000 4000 4000 6470 4000 7197 4000 4000 4000 8549 12069 8549 4000 4000 7704 11535 7704 7704 12142 8438 8438 13731 9293 13081 16766 13081 9293 4000 8528 8528 13865 9337 4000 4000 4000 11792 4000 4000 9725 15879 9725 4000 4000 10932 17338 10932 16773 16773 16724 17876 16736 10944 10944 4000 4000 4000 ...
result:
ok 200 lines
Test #45:
score: 7
Accepted
time: 40ms
memory: 27052kb
input:
100000 2000 10000 1 2 210 1 3 952 1 4 1579 1 5 1678 1 6 1852 1 7 519 1 8 1331 1 9 799 1 10 1625 1 11 1972 1 12 916 1 13 174 1 14 221 1 15 1695 1 16 274 1 17 603 1 18 396 1 19 1401 1 20 916 1 21 1627 1 22 1666 1 23 859 1 24 1943 1 25 439 1 26 204 1 27 1183 1 28 475 1 29 301 1 30 589 1 31 1621 1 32 18...
output:
7989 8377 7989 4000 4000 8967 4000 10886 12341 5455 5455 5455 12379 16835 16835 17381 17381 18622 18963 18963 19015 19015 18582 19122 19122 19122 19122 19727 19727 19727 19239 19187 19187 18459 18118 17738 17496 17214 17139 17139 16944 16478 16392 16249 16249 16098 17216 16098 15833 15718 15613 1768...
result:
ok 2000 lines
Test #46:
score: 7
Accepted
time: 59ms
memory: 27072kb
input:
100000 20000 10000 1 2 448 1 3 1449 1 4 1568 1 5 376 1 6 773 1 7 701 1 8 725 1 9 504 1 10 1910 1 11 170 1 12 1057 1 13 957 1 14 76 1 15 1475 1 16 1719 1 17 1922 1 18 1541 1 19 959 1 20 558 1 21 1817 1 22 547 1 23 777 1 24 50 1 25 1767 1 26 668 1 27 1854 1 28 68 1 29 163 1 30 1336 1 31 178 1 32 853 1...
output:
4692 4692 4692 4692 4000 5609 5609 5609 4000 4173 4173 4000 4000 4000 4000 6211 6211 6211 6211 4000 6529 6529 6529 4000 6809 6809 6809 9906 14221 17759 17759 17047 13020 9906 6809 11008 8199 12064 16027 17651 14022 17039 18448 18448 17039 15460 14022 16743 17482 17482 17798 17482 17482 18131 18676 1...
result:
ok 20000 lines
Test #47:
score: 7
Accepted
time: 153ms
memory: 27168kb
input:
100000 100000 10000 1 2 1360 1 3 316 1 4 1031 1 5 768 1 6 1164 1 7 111 1 8 192 1 9 1120 1 10 1394 1 11 1477 1 12 141 1 13 880 1 14 433 1 15 1500 1 16 1365 1 17 1785 1 18 571 1 19 1784 1 20 853 1 21 313 1 22 744 1 23 1410 1 24 1807 1 25 1073 1 26 498 1 27 964 1 28 1943 1 29 999 1 30 423 1 31 798 1 32...
output:
4000 4000 4000 4000 4479 4479 4000 5675 5675 5675 9824 15157 16514 17214 16514 15157 9824 8149 11776 14495 17805 15608 15086 19203 15086 7627 7627 12253 14489 14489 14489 14532 14489 13658 11422 15058 14890 14419 17275 14419 18328 14419 7156 7156 4000 10243 16084 17974 17976 17974 19483 17995 17593 ...
result:
ok 100000 lines
Subtask #4:
score: 0
Wrong Answer
Test #48:
score: 18
Accepted
time: 0ms
memory: 24020kb
input:
1000 1000 10000 1 2 503 1 3 889 2 4 6 2 5 1468 3 6 102 3 7 464 4 8 658 4 9 1642 5 10 1956 5 11 420 6 12 1287 6 13 1051 7 14 48 7 15 678 8 16 1662 8 17 906 9 18 432 9 19 124 10 20 71 10 21 1624 11 22 268 11 23 1776 12 24 404 12 25 967 13 26 658 13 27 815 14 28 1196 14 29 1920 15 30 865 15 31 1227 16 ...
output:
24077 24129 24073 24255 24248 24175 24175 24175 23680 22461 22205 21721 21721 21710 21624 21372 21320 21300 21300 21300 21266 21204 21067 19844 19844 19607 20014 19601 19515 19261 19244 19191 19166 19166 19107 19107 19107 19074 19074 19071 19071 19071 19082 19071 19013 18375 18200 19061 19061 19061 ...
result:
ok 1000 lines
Test #49:
score: 0
Wrong Answer
time: 18ms
memory: 22008kb
input:
1000 10000 10000 1 2 982 1 3 287 2 4 1144 2 5 1024 3 6 1485 3 7 1624 4 8 918 4 9 954 5 10 1897 5 11 598 6 12 976 6 13 106 7 14 1856 7 15 603 8 16 877 8 17 420 9 18 1629 9 19 1838 10 20 1323 10 21 1857 11 22 765 11 23 1531 12 24 1464 12 25 415 13 26 50 13 27 112 14 28 1369 14 29 47 15 30 1011 15 31 2...
output:
26037 26037 26665 26665 25619 25379 25220 25220 25220 25385 25220 25220 25471 25708 24885 24857 24058 23808 23808 23742 23742 23742 23742 23644 23576 23486 23399 23399 23399 23399 23352 23334 23240 23201 22897 22835 22835 22850 22753 22698 23153 23076 22265 22153 22269 22153 21995 21766 21766 21235 ...
result:
wrong answer 849th lines differ - expected: '14248', found: '14274'
Subtask #5:
score: 16.6667
Accepted
Test #65:
score: 16.6667
Accepted
time: 440ms
memory: 27004kb
input:
100000 100000 20000000000000 36784 60773 140153248 61611 56014 4384507 39699 81699 3960320 64081 33880 136970044 38189 43550 67958946 16177 77482 151567728 90206 77109 108497900 42376 92541 75503161 10148 21587 195080992 11109 80580 11975495 8506 81405 144971319 85501 69547 59675956 72008 46890 3423...
output:
20075213641185 20075213641185 20075213641185 20075213641185 20075213641185 20075213641185 20075213641185 20075213641185 20075213641185 20075213641185 20075213641185 20075213641185 20075213641185 20075213641185 20075213641185 20075213641185 20075213641185 20075213641185 20075213641185 20075213641185 ...
result:
ok 100000 lines
Test #66:
score: 16.6667
Accepted
time: 481ms
memory: 27280kb
input:
100000 100000 20000000000000 83246 45047 85765278 58645 15461 69329535 80366 26735 198967409 74006 76088 149781878 73707 62070 191884010 80303 46275 92792716 24142 22269 52567040 16571 49165 169517408 1913 33731 148017143 38712 36234 101256531 75509 45056 106023383 38787 16928 120431653 27021 40627 ...
output:
40071305542068 40071305542068 40071305542068 40071305542068 40071305542068 40071305542068 40071305542068 40071305542068 40071305542068 40071305542068 40071305542068 40071305542068 40071305542068 40071305542068 40071305542068 40071305542068 40071305542068 40071305542068 40071305542068 40071305542068 ...
result:
ok 100000 lines
Test #67:
score: 16.6667
Accepted
time: 453ms
memory: 27224kb
input:
100000 100000 20000000000000 43884 22995 170293147 63097 43276 94570164 76762 4628 183555213 85598 57388 135403480 5007 99372 95409014 56607 13862 114784522 25641 28303 13189457 49889 81556 36377659 97205 27534 188388960 32913 62303 86183929 48759 73120 27136304 79676 30674 23508285 44609 65286 8325...
output:
40076431259330 40076431259330 40076431259330 40076431259330 40076431259330 40076431259330 40076431259330 40076431259330 40076431259330 40076431259330 40076431259330 40076431259330 40076431259330 40076431259330 40076431259330 40076431259330 40076431259330 40076431259330 40076431259330 40076431259330 ...
result:
ok 100000 lines
Test #68:
score: 16.6667
Accepted
time: 460ms
memory: 27248kb
input:
100000 100000 20000000000000 35295 64109 182212365 99052 88660 135810979 39241 78510 80950881 32867 97876 168668908 37064 94184 57073243 79728 5092 109307804 91172 59365 44209792 40869 84160 16431336 58972 86625 192104928 44279 26623 1810486 94466 4090 15674108 62345 63809 62904991 4751 37916 164390...
output:
40076535295890 40076535295890 40076535295890 40076535295890 40076535295890 40076535295890 40076535295890 40076535295890 40076535295890 40076535295890 40076535295890 40076535295890 40076535295890 40076535295890 40076535295890 40076535295890 40076535295890 40076535295890 40076535295890 40076535295890 ...
result:
ok 100000 lines
Test #69:
score: 16.6667
Accepted
time: 454ms
memory: 27204kb
input:
100000 100000 20000000000000 92900 44409 59207708 1 63066 19999999999999 21380 22755 129554566 85178 32456 71206712 33393 6737 38072623 1 61793 19999999999999 44921 56043 16223429 46102 10181 136329263 48597 27863 80655282 22378 76874 191700870 98199 22735 107318322 89844 37548 170227908 23345 42404...
output:
40072048129540 40072048129540 40072048129540 40072048129540 40072048129540 40072048129540 40072048129540 40072048129540 40072048129540 40072048129540 40072048129540 40072048129540 40072048129540 40072048129540 40072048129540 40072048129540 40072048129540 40072047610493 40072047610493 40072047610493 ...
result:
ok 100000 lines
Test #70:
score: 16.6667
Accepted
time: 388ms
memory: 27128kb
input:
100000 100000 20000000000000 4790 10561 155251875 31202 15269 196582752 22423 19198 193938450 1 1123 19999999999999 17191 31875 144137508 1 33680 19999999999999 80522 89242 25506022 47208 86529 32959421 1 59550 19999999999999 40876 35555 62677290 1 94218 19999999999999 38258 64791 92421826 1 62916 1...
output:
40069713487601 40069713487601 40069713487601 40069713487601 40069713487601 40069713487601 40069713487601 40069713487601 40069713487601 40069713487601 40069713487601 40069713487601 40069713487601 40069713487601 40069713487601 40069713487601 40069713487601 40069713487601 40069713487601 40069713487601 ...
result:
ok 100000 lines
Test #71:
score: 16.6667
Accepted
time: 293ms
memory: 30480kb
input:
100000 100000 20000000000000 98627 62551 85542439 184 6404 199091973 80475 45223 126796098 82011 86355 44883357 12745 87626 122851694 32483 35456 42647637 57591 51881 119379687 14234 70197 18414316 14445 60713 185134817 60135 60632 64249287 97158 57823 123131155 26171 97136 126227518 17345 31802 135...
output:
23803663146980 23803478797682 23803478797682 23803478797682 23803478797682 23803478797682 23803489268686 23803464953954 23803464953954 23803402998273 23803402998273 23803402998273 23803402998273 23803342404482 23803396052527 23803396052527 23803362313965 23803478149972 23803478149972 23803399693934 ...
result:
ok 100000 lines
Test #72:
score: 16.6667
Accepted
time: 302ms
memory: 30764kb
input:
100000 100000 20000000000000 11386 49318 59499894 59805 4485 114231931 6000 95599 32453015 59963 69488 132655058 71707 95890 107114493 25078 41195 54398746 85141 72636 35482939 86496 57926 152726955 47713 61911 109511333 68294 78698 26050866 40447 16966 64581331 48256 35646 182914095 21756 91430 553...
output:
43801526223442 43801526223442 43801358945703 43801358945703 43801466160512 43801484441048 43801484441048 43801484441048 43801484441048 43801659727936 43801659727936 43801659727936 43801697128994 43801622054137 43801622054137 43801622054137 43801622054137 43801622054137 43801717362984 43801717362984 ...
result:
ok 100000 lines
Test #73:
score: 16.6667
Accepted
time: 276ms
memory: 30692kb
input:
100000 100000 20000000000000 5016 61821 155641413 152 63003 22335896 29281 61442 99868078 75758 27215 73519760 79388 83149 93709325 40010 76703 23618190 65712 68949 92611747 82318 55003 185846597 59688 59935 145789696 55458 85608 127085727 65604 82902 145754573 71932 61840 31891174 85781 82305 11251...
output:
43794674785300 43794674785300 43794674785300 43794694168491 43794574472384 43794574472384 43794574472384 43794630036977 43794721723014 43794778665513 43794778665513 43794778665513 43794777741905 43794777741905 43794777741905 43794777741905 43794930430495 43794930430495 43795011440013 43795011440013 ...
result:
ok 100000 lines
Test #74:
score: 16.6667
Accepted
time: 281ms
memory: 30696kb
input:
100000 100000 20000000000000 84003 85000 53401833 2835 34919 15889014 94896 60412 124414455 87064 21615 110164347 85704 19775 123536900 61997 49652 22249719 18261 22180 178662118 69519 1400 99292881 99596 51129 30565626 75575 94637 88671289 22974 2671 74216830 28130 98982 198280153 55626 86972 10129...
output:
43787428406550 43787428406550 43787493972823 43787493972823 43787450761971 43787556250196 43787556250196 43787660040748 43787660040748 43787660040748 43787660040748 43787660040748 43787660040748 43787660040748 43787660040748 43787713650150 43787713650150 43787603606152 43787787646305 43787787646305 ...
result:
ok 100000 lines
Test #75:
score: 16.6667
Accepted
time: 291ms
memory: 30592kb
input:
100000 100000 20000000000000 88347 31645 4990076 15511 81532 44067247 75408 73608 22721964 98537 66334 30509046 30737 29864 199323765 1 74174 19999999999999 1 20956 19999999999999 1 79348 19999999999999 910 16022 160081196 19415 86646 178912783 42942 72883 106472049 54329 3822 37898694 93443 66183 8...
output:
43652602047371 43652602047371 43652606332803 43652606332803 43652621045221 43652621045221 43652621045221 43652614122267 43652614122267 43652651502038 43652727162279 43652727162279 43652727162279 43652727162279 43652727162279 43652727162279 43652727162279 43652727162279 43652727162279 43652727162279 ...
result:
ok 100000 lines
Test #76:
score: 16.6667
Accepted
time: 226ms
memory: 29748kb
input:
100000 100000 20000000000000 1 14343 19999999999999 1 30185 19999999999999 91614 28749 196947911 60284 41163 31997619 1 13883 19999999999999 1 7365 19999999999999 89598 941 189936074 56254 66432 185009921 88336 85046 96160452 58388 53866 127731852 1 31154 19999999999999 1 63381 19999999999999 424 88...
output:
42817880292005 42817723721402 42817646275614 42817616816961 42817479016311 42817620308683 42817620308683 42817504807031 42817504807031 42817354249959 42817354249959 42817354249959 42817363356026 42817363356026 42817295219398 42817446073561 42817307007073 42817307007073 42817307007073 42817350636022 ...
result:
ok 100000 lines
Test #77:
score: 16.6667
Accepted
time: 192ms
memory: 36472kb
input:
100000 100000 20000000000000 12285 81691 177069285 41584 67836 89456987 40336 38244 129696536 30720 84603 118414897 62193 98138 101928887 16549 95676 32200510 95529 65848 149883635 97642 22008 190431417 29824 91956 180732131 50122 45341 74308105 10623 19707 163518587 30325 79023 88338898 13527 42707...
output:
30034368178674 30034426529513 30034488953241 30034431892469 30034301657585 30034324455771 30034327641924 30034212052139 30034118091656 30034043756258 30033991250132 30034086017830 30034084268603 30033938233674 30033852280631 30033810233361 30033840011157 30033839955227 30033893314025 30033887740487 ...
result:
ok 100000 lines
Test #78:
score: 16.6667
Accepted
time: 183ms
memory: 36544kb
input:
100000 100000 20000000000000 64273 93700 162554062 63953 3007 48982765 59096 67809 96685549 11380 64734 142736453 23839 48195 129143029 47054 8821 38772182 1859 23154 60248168 95363 62801 9770583 4547 38836 68951698 95343 6493 5319141 99588 12324 78648293 14890 15804 36317210 25199 67594 196424206 6...
output:
49994965588735 49994980114831 49995088054877 49995087705337 49994997204672 49994997732731 49995043669206 49995038942599 49994911705421 49994917935771 49995041604919 49994976764443 49994996047759 49994959683897 49994910360266 49994992783143 49995190734496 49995111183621 49995081003892 49994999609151 ...
result:
ok 100000 lines
Test #79:
score: 16.6667
Accepted
time: 215ms
memory: 36028kb
input:
100000 100000 20000000000000 53079 86362 45475705 39147 36829 116045175 5093 94274 198665356 34368 47423 171505312 12681 88582 103797984 5669 63168 21283247 15727 82109 145353768 51974 81587 113128765 37638 78723 125103242 57298 57984 20968514 82069 48351 188483900 35520 68600 55090291 60013 58047 1...
output:
49983016278136 49983028209740 49983071333298 49983091761773 49983150226609 49983164132063 49983084416292 49983213492307 49983288812135 49983260793258 49983101299260 49983202136999 49983136563273 49982960929186 49983108632372 49983083846972 49983131841945 49983010198823 49983035152997 49983104610653 ...
result:
ok 100000 lines
Test #80:
score: 16.6667
Accepted
time: 195ms
memory: 36320kb
input:
100000 100000 20000000000000 31747 78067 87773551 19888 20554 76559109 43850 23502 176182503 78018 8241 130460539 8382 41263 93650637 2873 69288 94021623 45094 16871 107101217 13378 32090 144041571 1 56919 19999999999999 79498 87441 38747318 64490 64437 148434214 78819 83757 113512974 57774 63988 47...
output:
49920817849412 49920800586755 49920755207295 49920744308735 49920778760662 49920751977601 49920796032406 49920668182242 49920711973844 49920798990860 49920747886554 49920779051545 49920735000181 49920765285061 49920688331304 49920762259072 49920600270999 49920514422589 49920677017970 49920613501447 ...
result:
ok 100000 lines
Test #81:
score: 16.6667
Accepted
time: 197ms
memory: 35508kb
input:
100000 100000 20000000000000 50556 87800 154470551 94717 1512 184618950 80492 44324 185041606 14379 18439 165484412 46802 7770 187600476 32926 54947 49018914 14308 91746 193720837 27723 74119 109834565 13087 21847 199235641 61917 1552 107008760 1 12124 19999999999999 23808 28262 120389710 1182 57333...
output:
48990802051708 48990875691892 48990917995642 48990968629311 48990973557385 48991107012772 48991022477204 48991005389140 48990878196808 48990966658585 48990842269187 48990899105057 48990922390712 48990946634142 48990960017835 48991024604279 48990967103195 48991041449273 48991054036969 48991140242690 ...
result:
ok 100000 lines
Test #82:
score: 16.6667
Accepted
time: 173ms
memory: 31796kb
input:
100000 100000 20000000000000 64899 82015 95034430 1 28919 19999999999999 1 887 19999999999999 1 10427 19999999999999 1 92034 19999999999999 1 91011 19999999999999 71894 94756 139376823 1 31659 19999999999999 1 17903 19999999999999 1 50313 19999999999999 1 7403 19999999999999 1 68027 19999999999999 1...
output:
45013273882625 45013264288517 45013199123948 45013338302747 45013338292203 45013293081584 45013283757921 45013459885625 45013340932509 45013184001522 45013199408654 45013247335394 45013156216355 45013200669665 45013012824666 45013091537940 45013187890296 45013328961718 45013454688146 45013422578194 ...
result:
ok 100000 lines
Test #83:
score: 16.6667
Accepted
time: 198ms
memory: 36484kb
input:
100000 100000 20000000000000 23766 51470 155285023 71598 81610 122609965 45909 79934 195297961 62656 95268 28013892 12212 25465 65538651 85981 58101 134109958 42504 92634 93121525 3048 22788 159039733 67819 44111 11349656 48098 19775 134419403 58632 89411 51985841 17673 5395 41681723 50627 35941 530...
output:
30000266345076 30000276656988 30000329542149 30000372252596 30000354658507 30000223681591 30000239734638 30000177874004 30000072679719 30000197727128 30000244707318 30000222115039 30000206763047 30000218717899 30000266408768 30000384414165 30000479622903 30000478696348 30000503958748 30000478722001 ...
result:
ok 100000 lines
Test #84:
score: 16.6667
Accepted
time: 198ms
memory: 36488kb
input:
100000 100000 20000000000000 91715 22250 11742542 89182 16465 142439285 20728 87227 116827453 81422 95172 92656850 24348 66046 14101857 9730 25708 22550257 45906 93964 101983608 40847 20887 177840129 77595 59920 18386493 33184 46095 44593656 20466 39295 11366763 51666 75644 16155905 96509 60987 6883...
output:
50031140357136 50031110093056 50030963245268 50031114316202 50031088316484 50031111316805 50031205682160 50031322786475 50031321391870 50031362846621 50031462218721 50031483987060 50031367414403 50031312484992 50031288675064 50031342747261 50031250940476 50031121412242 50031115831191 50031097291317 ...
result:
ok 100000 lines
Test #85:
score: 16.6667
Accepted
time: 210ms
memory: 36532kb
input:
100000 100000 20000000000000 1392 37981 70328382 48037 77939 106008879 70949 49143 159960090 48853 14496 21612385 39735 39326 180293785 10746 96137 96997929 91890 46694 129615594 27994 70103 54583825 69026 90303 39755984 66562 94651 102738147 87211 87508 88729409 11199 88618 132386556 21005 14398 92...
output:
49954388102428 49954219115817 49954139934676 49953976613156 49953950124510 49953933570056 49954021731587 49953995429480 49953950310047 49954001041728 49953979394406 49953878845960 49953753721933 49953799180232 49953748791113 49953722283565 49953754753245 49953770643965 49953783671600 49953798219368 ...
result:
ok 100000 lines
Test #86:
score: 16.6667
Accepted
time: 202ms
memory: 36064kb
input:
100000 100000 20000000000000 50878 58179 65236679 80171 10852 3198230 20546 36171 6935180 20946 46710 125785485 29081 74033 63615292 5104 20193 189131960 98665 16087 185730390 65692 6977 162468733 34294 68029 37350656 290 84790 131747933 50415 9989 34558789 21430 26917 123660866 61401 40420 17961164...
output:
49895850235344 49895923569615 49895852953903 49895859191460 49895782712748 49895799855967 49895858149327 49895837704143 49895867617510 49895899014769 49895865669655 49895940825741 49895902877668 49895913663099 49896029460641 49895970360870 49895956129559 49895913470292 49895899435258 49895942948010 ...
result:
ok 100000 lines
Test #87:
score: 16.6667
Accepted
time: 199ms
memory: 34756kb
input:
100000 100000 20000000000000 13523 40862 140243082 30993 23769 89615539 20177 88020 121194096 66905 76279 179765270 57323 19118 17107375 47339 24029 3775232 64269 40644 198918384 2319 45958 194407806 91807 55473 59001580 71331 40113 93761260 17849 58238 53043396 69107 5445 105785318 16757 97793 1241...
output:
49003874783584 49003925276024 49003965645403 49004085187267 49003973954966 49003987553441 49003976664783 49003947580550 49003826779274 49003856678251 49003839179699 49003981686375 49003897794451 49003889986987 49003884070728 49003953892504 49003946514214 49003784013286 49003818226112 49003655355809 ...
result:
ok 100000 lines
Test #88:
score: 16.6667
Accepted
time: 177ms
memory: 31852kb
input:
100000 100000 20000000000000 1 78459 19999999999999 19531 86306 109730394 68246 45636 62312847 1 40223 19999999999999 1 50944 19999999999999 43388 35778 123571482 95213 26405 107621545 1 36282 19999999999999 1 40964 19999999999999 63940 9961 175045310 1 1042 19999999999999 13366 42019 98662402 24620...
output:
44988472324663 44988511452729 44988589647892 44988503267605 44988414705631 44988412709212 44988374790127 44988387157528 44988525206668 44988381571334 44988400941011 44988401746418 44988532948733 44988650971602 44988664944987 44988645863514 44988753662988 44988819131571 44988818465152 44988805890585 ...
result:
ok 100000 lines
Subtask #6:
score: 0
Skipped
Dependency #1:
0%