QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#436962 | #8787. Unusual Case | ucup-team1766# | AC ✓ | 1205ms | 45764kb | C++23 | 6.3kb | 2024-06-09 03:58:18 | 2024-06-09 03:58:20 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
namespace hamil {
template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second
#define ll long long
namespace LCT {
vector<vi> ch;
vi fa, rev;
void init(int n) {
ch.resize(n + 1);
fa.resize(n + 1);
rev.resize(n + 1);
for (int i = 0; i <= n; i++)
ch[i].resize(2),
ch[i][0] = ch[i][1] = fa[i] = rev[i] = 0;
}
bool isr(int a)
{
return !(ch[fa[a]][0] == a || ch[fa[a]][1] == a);
}
void pushdown(int a)
{
if(rev[a])
{
rev[ch[a][0]] ^= 1, rev[ch[a][1]] ^= 1;
swap(ch[a][0], ch[a][1]);
rev[a] = 0;
}
}
void push(int a)
{
if(!isr(a)) push(fa[a]);
pushdown(a);
}
void rotate(int a)
{
int f = fa[a], gf = fa[f];
int tp = ch[f][1] == a;
int son = ch[a][tp ^ 1];
if(!isr(f))
ch[gf][ch[gf][1] == f] = a;
fa[a] = gf;
ch[f][tp] = son;
if(son) fa[son] = f;
ch[a][tp ^ 1] = f, fa[f] = a;
}
void splay(int a)
{
push(a);
while(!isr(a))
{
int f = fa[a], gf = fa[f];
if(isr(f)) rotate(a);
else
{
int t1 = ch[gf][1] == f, t2 = ch[f][1] == a;
if(t1 == t2) rotate(f), rotate(a);
else rotate(a), rotate(a);
}
}
}
void access(int a)
{
int pr = a;
splay(a);
ch[a][1] = 0;
while(1)
{
if(!fa[a]) break;
int u = fa[a];
splay(u);
ch[u][1] = a;
a = u;
}
splay(pr);
}
void makeroot(int a)
{
access(a);
rev[a] ^= 1;
}
void link(int a, int b)
{
makeroot(a);
fa[a] = b;
}
void cut(int a, int b)
{
makeroot(a);
access(b);
fa[a] = 0, ch[b][0] = 0;
}
int fdr(int a)
{
access(a);
while(1)
{
pushdown(a);
if (ch[a][0]) a = ch[a][0];
else {
splay(a);
return a;
}
}
}
}
vi out, in;
vi work(int n, vector<pi> eg, ll mx_ch = -1) {
// mx_ch : max number of adding/replacing default is (n + 100) * (n + 50)
// n : number of vertices. 1-indexed.
// eg: vector<pair<int, int> > storing all the edges.
// return a vector<int> consists of all indices of vertices on the path. return empty list if failed to find one.
out.resize(n + 1), in.resize(n + 1);
LCT::init(n);
for (int i = 0; i <= n; i++) in[i] = out[i] = 0;
if (mx_ch == -1) mx_ch = 1ll * (n + 100) * (n + 50); //default
vector<vi> from(n + 1), to(n + 1);
for (auto v : eg)
from[v.fi].pb(v.se),
to[v.se].pb(v.fi);
unordered_set<int> canin, canout;
for (int i = 1; i <= n; i++)
canin.insert(i),
canout.insert(i);
mt19937 x(chrono::steady_clock::now().time_since_epoch().count());
int tot = 0;
while (mx_ch >= 0) {
// cout << tot << ' ' << mx_ch << endl;
vector<pi> eg;
for (auto v : canout)
for (auto s : from[v])
if (in[s] == 0) {
assert(canin.count(s));
continue;
}
else eg.pb(mp(v, s));
for (auto v : canin)
for (auto s : to[v])
eg.pb(mp(s, v));
shuffle(eg.begin(), eg.end(), x);
if (eg.size() == 0) break;
for (auto v : eg) {
mx_ch--;
if (in[v.se] && out[v.fi]) continue;
if (LCT::fdr(v.fi) == LCT::fdr(v.se)) continue;
if (in[v.se] || out[v.fi])
if (x() & 1) continue;
if (!in[v.se] && !out[v.fi])
tot++;
if (in[v.se]) {
LCT::cut(in[v.se], v.se);
canin.insert(v.se);
canout.insert(in[v.se]);
out[in[v.se]] = 0;
in[v.se] = 0;
}
if (out[v.fi]) {
LCT::cut(v.fi, out[v.fi]);
canin.insert(out[v.fi]);
canout.insert(v.fi);
in[out[v.fi]] = 0;
out[v.fi] = 0;
}
LCT::link(v.fi, v.se);
canin.erase(v.se);
canout.erase(v.fi);
in[v.se] = v.fi;
out[v.fi] = v.se;
}
if (tot == n - 1) {
vi cur;
for (int i = 1; i <= n; i++)
if (!in[i]) {
int pl = i;
while (pl) {
cur.pb(pl),
pl = out[pl];
}
break;
}
return cur;
}
}
//failed to find a path
return vi();
}
}
int main() {
cin.tie(0)->sync_with_stdio(0);
int n, m, k; cin >> n >> m >> k;
vector adj(n + 1, set<int>());
while (m--) {
int a, b; cin >> a >> b;
adj[a].emplace(b);
adj[b].emplace(a);
}
while (k--) {
vector<pair<int, int>> edges;
for (int i = 1; i <= n; i++)
for (int j : adj[i])
edges.emplace_back(i, j);
auto path = hamil::work(n, edges);
for (auto v : path) cout << v << ' ';
cout << '\n';
for (unsigned i = 1; i < path.size(); i++) {
adj[path[i - 1]].erase(path[i]);
adj[path[i]].erase(path[i - 1]);
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3656kb
input:
5 9 2 1 3 1 4 1 5 2 3 2 4 2 5 3 5 4 3 5 4
output:
2 4 3 5 1 3 1 4 5 2
result:
ok OK (n = 5, m = 9)
Test #2:
score: 0
Accepted
time: 1092ms
memory: 43924kb
input:
10000 200000 8 6318 9948 9588 8985 4252 4927 1146 9347 2276 7434 9612 4436 8319 1837 4428 1043 5976 2759 879 1564 7866 4849 2070 5310 8407 156 7306 7766 9100 1576 1181 6122 7790 7065 3235 8877 5661 9718 1555 743 5479 9755 2601 8190 3318 2067 4084 8193 1050 269 64 5504 3416 5041 7169 197 2158 2523 57...
output:
6107 2906 5643 7513 8245 9856 2241 1556 2291 7299 7850 8017 6684 4209 8852 6186 3715 4691 4021 4904 4251 4256 1587 588 5456 3839 849 5684 1734 2472 330 6616 8886 8738 2211 81 7639 5124 3353 3068 1417 1142 1245 6898 2950 4663 939 5149 6732 3981 2207 9059 1911 8785 3863 3197 1333 8177 4015 4862 4646 1...
result:
ok OK (n = 10000, m = 200000)
Test #3:
score: 0
Accepted
time: 1048ms
memory: 44464kb
input:
10000 200000 8 7826 9720 8400 2487 6964 6011 4799 6032 3696 3691 7883 4350 9092 3892 3588 7409 6005 4538 4196 7873 4216 4505 6339 1269 2405 5423 9 7030 8193 7285 5782 2768 5646 4946 4483 6857 3431 9325 4243 488 2435 8371 3067 1462 8592 4932 8581 3147 1394 6751 2499 4977 4806 1190 9652 5059 4075 3454...
output:
2049 561 9129 693 8744 7571 6347 1245 6940 9177 9617 6067 3346 232 5578 6608 7927 9585 5802 2261 7748 9868 9771 2158 6575 4527 5468 9879 7116 2127 7020 3599 9772 8620 939 4122 164 3763 6030 2065 937 3041 1537 9543 2169 6436 9989 2939 3293 3645 2032 5785 3056 8208 9341 1497 2139 176 9054 9075 3104 24...
result:
ok OK (n = 10000, m = 200000)
Test #4:
score: 0
Accepted
time: 1029ms
memory: 44008kb
input:
10000 200000 8 6064 4200 2244 5165 648 6303 9246 8103 4187 7801 761 3539 6105 2254 4471 3158 6006 4452 3580 8120 9391 3711 8752 1014 2511 151 800 2285 5388 3282 4704 8712 5372 5509 6988 6976 9314 9056 2225 9256 8567 3853 4135 3386 9688 1467 7287 5856 8107 7114 2385 3663 2991 2969 3746 7352 8828 6735...
output:
3924 8390 5093 774 911 626 1177 2714 1146 2386 4133 7251 436 1720 9691 5073 5202 703 1182 5884 128 3783 7449 7792 4162 3245 7917 7397 3459 2691 7632 54 4347 4144 4120 7361 7126 9923 8644 695 3466 2070 8875 3339 2763 8677 6495 5492 6562 6092 1507 2464 9829 7950 9504 6081 9006 2575 4615 7278 6243 2738...
result:
ok OK (n = 10000, m = 200000)
Test #5:
score: 0
Accepted
time: 1025ms
memory: 43656kb
input:
10000 200000 8 1034 3387 1120 7020 5302 5802 4487 5560 3749 9763 8246 2002 9358 6922 7077 8289 5976 2501 9030 2306 3390 2468 9307 4546 8724 4342 9679 3531 684 9564 7946 3956 6968 8754 748 9234 3310 8909 5500 7046 3874 6201 5806 3962 6604 1672 203 6318 1189 1358 9723 1561 7970 380 9450 7078 6420 2366...
output:
7895 859 7924 3319 5710 8508 1528 4925 9130 4502 6133 8687 7668 2969 9994 39 3157 1769 3889 3797 173 9861 4140 8804 4717 663 514 7608 283 3201 4416 6505 4822 1085 8426 5075 7284 1440 8183 4927 7743 5202 8215 3641 3134 608 3782 1842 3910 2074 5270 3931 4238 6642 2418 2188 2554 5653 5315 4132 8100 209...
result:
ok OK (n = 10000, m = 200000)
Test #6:
score: 0
Accepted
time: 1142ms
memory: 44236kb
input:
10000 200000 8 2734 7281 5027 8050 927 4507 523 8404 2382 9578 337 9740 8851 7897 1407 2803 5918 8684 547 430 6215 775 8004 1864 1045 7995 6645 767 4082 6133 5510 8499 433 4681 5763 3631 5419 8885 4068 3859 8356 5416 8078 3190 9342 5547 7329 4533 639 9483 4511 8673 9744 3422 6765 4236 6849 346 2288 ...
output:
3394 1985 2010 2714 1636 4503 3686 8826 809 70 6248 958 7792 505 9856 6453 7806 6152 7264 2738 193 326 6624 7011 9908 6051 3258 2349 7103 3306 5355 8040 8653 331 2941 9966 5912 7688 2691 2608 2136 5182 234 2017 6174 3404 7510 5462 8674 8295 344 6319 5869 5676 3582 778 7369 8848 3184 3111 5416 5956 2...
result:
ok OK (n = 10000, m = 200000)
Test #7:
score: 0
Accepted
time: 1065ms
memory: 44176kb
input:
10000 200000 8 1166 5882 3966 8257 7523 2420 7353 6633 87 7247 7035 6751 4585 5179 7460 6699 5829 3002 8131 2493 7864 8632 4845 2969 9472 1110 1698 3993 5582 2988 7395 2341 5768 3290 2034 167 5642 8983 7929 9694 2014 1497 952 1069 7900 3092 8663 502 6458 1489 6751 4998 8312 2094 5690 8825 115 676 62...
output:
6110 5699 8328 6480 9904 4300 9744 7579 5709 5463 9562 6856 804 2022 693 4009 4476 6504 6198 7138 9568 4148 1503 5878 7456 4465 404 2769 2573 9698 2087 7932 2310 1346 6626 2372 5845 2406 6069 1360 1362 4975 6901 3524 6306 4854 3123 2373 1018 2944 9419 1602 6142 8407 8818 9420 8902 9819 6995 3330 329...
result:
ok OK (n = 10000, m = 200000)
Test #8:
score: 0
Accepted
time: 1131ms
memory: 43984kb
input:
10000 200000 8 6328 9191 7937 7640 5090 9539 4977 248 6863 2768 8341 3037 6559 8768 5237 9978 5712 5454 1782 8494 8338 6040 9828 7861 4008 3687 4839 3210 5183 130 3601 5482 2972 4581 9560 8842 3978 9205 7084 4551 4847 4445 4428 7601 2280 4306 4207 4225 8646 7376 6443 536 3674 6398 6226 847 6219 3356...
output:
2130 5088 9943 7463 1817 78 3892 2380 7550 4590 7438 24 29 5941 3708 4261 1573 7833 2787 7514 8375 1802 8875 6925 6662 2460 7331 4005 7954 7601 9690 4707 6062 2578 5344 7186 7817 7276 6826 1411 2363 2895 4787 5419 406 6299 2960 5731 7241 7170 303 4784 8554 6100 3291 9123 1187 8902 3946 4129 9201 160...
result:
ok OK (n = 10000, m = 200000)
Test #9:
score: 0
Accepted
time: 1205ms
memory: 44140kb
input:
10000 200000 8 8222 7206 6939 6199 3627 5866 3396 9250 2710 6141 4253 8597 4773 8663 4738 2640 5564 6042 1500 8433 7637 2998 2954 6540 4650 5727 6068 8417 2885 7557 4129 7922 2046 8554 8343 9655 428 9550 1531 8431 6855 4259 8506 2784 2481 9190 3961 5701 7203 7144 3585 5286 5830 6332 8372 300 5160 83...
output:
3562 9294 7115 9085 6969 5407 8629 6042 2133 2272 2656 3487 8897 9291 5277 7396 7030 285 7294 8087 305 4786 5194 9024 8476 3041 2326 2587 6990 6918 8097 4535 237 4496 9503 3818 3790 5572 1581 8714 6807 5907 7903 8390 8961 960 3102 3361 8722 8422 2601 6128 2550 7397 1912 2381 3396 2491 4123 8526 5167...
result:
ok OK (n = 10000, m = 200000)
Test #10:
score: 0
Accepted
time: 1104ms
memory: 44196kb
input:
10000 200000 8 6846 9929 974 3935 3136 1399 2610 3637 7628 7368 4772 3431 9227 4865 5962 4684 5388 4763 7285 2311 5760 9506 4223 9005 1401 7229 5384 9615 8690 5272 8977 9661 2990 5210 8380 2608 4990 18 1272 1334 8039 940 3186 6620 8503 7744 7924 4930 2128 794 8179 9250 4781 1898 2129 7185 6939 5764 ...
output:
2238 5035 6245 6506 3526 3593 3089 7542 960 7320 3184 231 8710 6430 5839 7822 2071 7269 2819 3735 5036 603 9390 9219 2476 6439 6141 7075 3079 5924 7437 6793 1569 7300 4327 320 1659 4200 650 364 3543 8569 1228 5363 989 3160 5410 8585 4018 7923 2021 3220 9436 2091 8814 1900 4484 9791 8761 6938 8311 84...
result:
ok OK (n = 10000, m = 200000)
Test #11:
score: 0
Accepted
time: 1113ms
memory: 43756kb
input:
10000 200000 8 2202 7359 40 846 3615 6140 2618 3411 1618 6447 9897 7539 9921 7374 8909 6111 5182 1620 9136 127 2709 5565 3635 5257 4258 8192 2787 6804 2596 3272 8146 700 5803 4547 9673 7699 7666 608 6306 3259 8398 4487 8468 9107 347 9968 6096 1913 3422 8324 225 2426 526 3095 7496 1502 1556 5493 1173...
output:
643 7669 3440 359 9053 9990 523 6395 1214 8119 8061 2742 1258 5153 9466 6237 1061 1379 4592 1527 7194 8852 3401 6019 6851 3826 2407 3555 4476 3102 6944 8367 3958 4049 2600 8040 8584 769 403 4039 9087 2399 6088 5681 9156 8630 9962 2882 4924 4157 5973 9152 9184 5723 1541 4004 9158 4248 8343 3579 879 3...
result:
ok OK (n = 10000, m = 200000)
Test #12:
score: 0
Accepted
time: 1027ms
memory: 45260kb
input:
10000 200000 8 4288 9496 4137 6934 5065 87 3420 8570 4679 3379 9630 921 6856 6189 3580 6921 4946 6611 7054 1882 8482 1173 1189 5296 3223 8618 8278 9983 4603 1559 1637 1037 487 6567 2222 4930 8456 1322 6633 4206 7932 4900 4352 246 8011 5862 8478 6650 1085 9736 9721 4816 3066 9922 4474 3251 9010 7571 ...
output:
5246 3551 2944 346 4776 6052 1567 9910 4218 3455 1850 7336 3460 4848 296 4596 4067 7821 1110 4990 6648 8806 152 8719 8767 8615 7725 7471 8963 906 5135 6898 7794 8896 1754 5719 6396 3776 4440 4599 5028 9328 6619 9208 577 2882 3848 7099 1265 1697 9914 6823 2394 3533 2028 5781 3760 7369 2314 7430 7817 ...
result:
ok OK (n = 10000, m = 200000)
Test #13:
score: 0
Accepted
time: 1073ms
memory: 44108kb
input:
10000 200000 8 3105 6341 3267 2198 7486 3241 5017 9116 6811 8164 3970 3578 30 1311 9975 7113 4681 9737 1039 7576 3081 6333 6886 9121 8295 8507 1857 9152 4712 132 9449 674 7039 1268 6027 4299 7358 2158 2254 4176 6642 2180 838 38 1497 5426 5069 9140 5117 5029 6669 6418 2399 2381 3063 2432 9302 1999 61...
output:
1217 186 3148 3628 2516 4891 6991 1465 3400 8876 4325 2514 5527 4710 9826 2815 4745 9452 6364 9112 509 8852 3777 195 3529 4867 6263 1783 6686 5407 5574 5041 1166 3193 1278 617 8836 9500 9324 8475 1597 5157 2577 2525 1511 4449 9649 109 9829 1404 7892 9998 3264 4010 1959 2890 9171 6484 8675 8294 3490 ...
result:
ok OK (n = 10000, m = 200000)
Test #14:
score: 0
Accepted
time: 1068ms
memory: 44644kb
input:
10000 200000 8 8654 7892 7428 6639 878 5603 7408 5048 8014 802 2916 5509 9445 2740 8092 6688 4386 998 1091 7207 6504 1042 726 6733 9475 7857 3523 4312 2923 8991 1582 9609 5462 8652 1087 5808 4374 3117 3167 3169 4526 6326 7925 8481 804 8660 5869 9384 5517 4202 1069 7233 8527 470 3262 9045 2431 8777 5...
output:
3508 9408 500 7208 3186 6347 6965 2390 3544 4859 3474 6018 3997 7171 7709 6157 5098 5866 473 5316 8445 1702 6616 2188 152 5828 4239 2099 7246 5715 3598 8053 7705 5130 9049 2266 7671 7465 438 4746 1175 6227 2690 4567 6398 7614 2903 3759 5804 5818 8129 9438 1984 6701 4967 1395 9577 1983 8984 2417 2977...
result:
ok OK (n = 10000, m = 200000)
Test #15:
score: 0
Accepted
time: 1128ms
memory: 44300kb
input:
10000 200000 8 933 4151 6621 255 5240 7171 594 6365 8289 1293 6469 6714 5100 476 7934 5646 4062 393 7210 778 8752 5302 2709 8132 6762 6670 3277 5462 9235 8137 8036 7844 5754 8718 7402 9455 9503 4199 9374 1184 1587 7339 5615 5576 5932 5563 879 7381 2286 7257 2919 7262 1450 4191 5071 3090 8398 7904 28...
output:
2621 6134 7302 2824 1681 1997 9111 1257 4 4047 7860 9274 5788 8077 3319 6347 8206 3608 6199 6165 2650 1053 3799 3539 418 1481 1455 9341 1093 6938 9059 282 151 3459 941 8624 8984 2870 6720 4293 2912 7478 429 2644 8102 4325 953 4362 8129 8382 6377 7272 1701 1775 8802 6593 4543 3290 7615 3697 7682 9622...
result:
ok OK (n = 10000, m = 200000)
Test #16:
score: 0
Accepted
time: 1051ms
memory: 44216kb
input:
10000 200000 8 9943 5117 846 3048 573 7946 4574 3069 7634 9636 4629 7193 6995 4518 9499 3986 3709 7923 9395 8286 9824 9113 2834 3317 156 4944 1118 2603 3649 7569 8811 5378 7915 1466 4973 5241 2746 5405 874 8222 7822 5218 3907 1322 6881 6137 98 3131 5423 4193 2221 6503 1167 3542 8491 4566 7202 9381 8...
output:
3988 4781 1242 7432 6081 5607 2854 1630 2031 9253 2946 5307 3441 7259 5028 3671 9814 6084 9540 6721 7977 2800 2456 7103 497 1141 4081 3235 6987 1948 9892 1440 9162 8368 3086 5058 7240 4957 4336 3088 1729 6382 5552 3929 5912 6921 7160 8844 2402 7610 1322 3907 3227 7346 7973 3075 3054 4188 7634 2035 2...
result:
ok OK (n = 10000, m = 200000)
Test #17:
score: 0
Accepted
time: 1057ms
memory: 43960kb
input:
10000 200000 8 5685 790 102 5017 6877 7928 9348 5159 6051 5832 7396 6946 5130 4867 2787 1709 3325 3587 7648 9733 9722 2473 1102 2289 9658 2681 7046 5735 6164 7288 3907 2211 1947 6896 3800 3166 4102 6733 7667 4282 3233 9964 2800 5721 3651 380 3526 6635 4930 5010 8974 4957 7678 8525 3522 3474 8844 320...
output:
3430 4549 6340 86 850 6751 2552 5518 9030 9995 5524 9518 5729 5753 3416 4234 680 5690 2460 546 4313 7083 996 8966 8015 5015 8575 3990 2852 2924 182 9938 6848 3458 8802 7552 7290 6358 9850 4592 2789 1638 8707 8411 5767 4918 3074 1988 9554 7044 4167 4216 1441 1795 8534 228 6997 2578 320 2417 8876 4374...
result:
ok OK (n = 10000, m = 200000)
Test #18:
score: 0
Accepted
time: 1056ms
memory: 43836kb
input:
10000 200000 8 8157 1170 4391 6162 4152 7117 4917 2635 3540 9882 4770 5974 9506 1523 7799 8814 2913 7387 1967 5119 8444 5384 7513 5048 5267 9880 1062 4857 6781 7292 3324 8343 7848 5008 3882 3230 3571 8184 9753 9364 7819 1576 2296 8772 6243 8293 1164 7893 805 9708 3179 2624 983 9138 163 9815 3323 938...
output:
5668 8575 3049 6710 8222 4836 5980 2545 491 1053 453 2854 2758 2140 3942 7873 8439 3509 6594 2994 9030 6091 2341 7552 5469 4793 550 4728 1550 8814 7819 4792 80 2501 1741 3649 3357 6071 4570 8271 759 7939 5941 195 8204 9928 6778 8634 833 7199 7035 7366 2818 258 8479 8946 5406 6828 7557 1866 9799 8060...
result:
ok OK (n = 10000, m = 200000)
Test #19:
score: 0
Accepted
time: 1016ms
memory: 44020kb
input:
10000 200000 8 7360 6258 3711 6484 2398 5513 1280 5497 99 1783 6751 4276 121 4485 4535 5302 2471 9321 2353 4443 5992 7845 2067 1594 6983 6541 3166 9969 5499 7584 7063 3774 5618 5802 5220 5433 1153 9758 7132 3469 1580 55 2393 474 4655 9876 3012 6904 3048 8287 4835 9504 1083 5383 8414 3587 640 7909 12...
output:
9567 508 2456 2491 4284 481 9575 6933 8784 4292 3078 5750 1733 8705 5454 4945 2117 1488 4542 2022 7101 7343 4715 6807 9721 5284 140 3002 2222 1096 117 3928 5444 7480 5073 7271 5082 6380 1652 5595 9838 5657 2589 1707 2179 8976 5686 8167 7155 9733 9148 6295 7078 2610 9221 9073 7650 9452 5306 3993 7731...
result:
ok OK (n = 10000, m = 200000)
Test #20:
score: 0
Accepted
time: 1071ms
memory: 44320kb
input:
10000 200000 8 3294 6053 8062 5981 1615 3116 8438 3745 5730 1538 3338 1852 6977 3755 2994 1173 1999 9389 8805 7705 2364 9857 4763 1926 4807 2665 3357 1072 2320 8161 5122 8504 5259 9278 7813 9775 6849 1454 9805 6597 4517 5400 3093 829 8889 5129 9068 3669 1661 747 3942 5597 7977 7258 8276 4791 794 878...
output:
9469 1972 9355 5545 6339 3898 2295 8442 707 6594 4448 8209 7471 4178 3879 6560 2566 2085 3221 1874 7152 8968 8562 3547 6799 4424 7556 9111 4943 5209 2314 9531 589 2317 6127 6282 8863 1199 5291 5687 7318 7258 8535 4616 9643 5600 5910 6578 7707 4586 2278 6818 5583 2485 4614 2823 9415 7441 1492 9115 81...
result:
ok OK (n = 10000, m = 200000)
Test #21:
score: 0
Accepted
time: 1123ms
memory: 43976kb
input:
10000 200000 8 5960 554 7446 4655 1802 9926 6390 7380 432 9145 4532 8702 73 9330 3176 6426 1498 7593 1325 4906 7561 1419 5603 6045 8738 8250 1636 8165 7241 9025 7503 2533 6769 5436 1662 6255 658 3274 7771 8747 6629 7611 4394 9835 8944 4052 9334 8187 6642 7088 500 903 1665 4765 9749 3427 3786 2010 29...
output:
6247 6696 8769 5664 6173 1328 728 4522 1334 3873 7879 8113 2621 8838 7288 4004 7125 4447 9987 2208 7648 7905 9270 1440 9460 230 7327 6107 3423 9801 1433 9747 4075 3839 8305 3678 6056 8776 7697 7591 5349 6750 1059 3411 2384 4433 8525 9965 4614 4648 6505 6456 673 4160 1060 8312 6972 7824 4839 3943 563...
result:
ok OK (n = 10000, m = 200000)
Test #22:
score: 0
Accepted
time: 1089ms
memory: 45328kb
input:
10000 200000 8 5356 9763 1861 2505 2960 5943 5137 6400 4205 4606 334 4826 9409 1213 5082 1062 968 3931 9911 6045 1583 2531 4585 3950 8777 3298 8002 1249 265 175 4205 5862 148 4277 6766 4875 2580 5217 1030 9919 7916 6689 6297 7493 4820 6644 3810 458 7992 7311 4510 5422 2148 7902 2832 9495 9616 7585 5...
output:
1568 3670 9186 7074 7715 518 787 884 1688 4569 8293 1366 8374 8501 4534 9162 822 4245 3016 1651 5577 6864 9251 6646 5264 2559 3516 8551 2571 1504 7348 8561 1517 8357 1609 6268 127 4339 9349 4347 5402 5793 7597 591 3423 9062 7134 7396 9151 505 8341 9486 4152 9260 8228 3304 9388 9986 2278 5856 3860 85...
result:
ok OK (n = 10000, m = 200000)
Test #23:
score: 0
Accepted
time: 1127ms
memory: 44520kb
input:
10000 200000 8 1483 3680 1308 9532 5089 1166 4678 806 7049 7919 742 225 4985 9402 8711 5081 408 8403 4565 1123 4429 3193 1709 5643 4923 7808 2456 324 1389 1611 5228 8489 5397 5799 3126 5633 2616 7282 9582 114 8379 2634 8802 3804 6517 2907 2495 483 5711 1414 5972 9154 9425 6671 7526 2994 8283 5509 64...
output:
2357 344 6066 7247 3274 523 1383 9074 6635 8983 6025 5794 6415 7381 7461 6256 3875 2958 1451 1172 9058 2141 2014 1252 7529 2747 1332 9789 9141 7641 3276 2167 4001 1311 3638 910 2252 1059 7861 706 3627 2650 9726 3619 7574 3137 4152 5407 6931 8381 1401 6839 3962 1653 9745 9177 9406 9591 835 3118 9350 ...
result:
ok OK (n = 10000, m = 200000)
Test #24:
score: 0
Accepted
time: 1086ms
memory: 42916kb
input:
10000 200000 8 4341 2303 5786 5734 8189 5597 5013 599 8965 9085 5757 4898 6801 3898 4064 8482 9819 1010 5285 139 6101 3406 6977 1121 7176 1780 4997 5389 616 3334 572 416 2516 4 742 8531 765 9471 3427 9332 8017 5445 1909 8766 4035 2839 5389 8262 9798 9399 4884 2098 3496 1070 3830 3926 9787 5783 4993 ...
output:
7301 2419 1729 278 501 3170 5159 981 1425 2750 5857 2932 9580 9740 9721 2799 6989 8957 7446 9832 6945 5724 4637 1790 5021 1980 4429 2166 7722 2202 4165 9487 803 7529 7490 3074 1490 7602 6643 7539 7632 2890 2554 1417 5191 9784 4902 2791 6693 9697 9453 3691 855 3525 6780 3684 4008 2988 8741 2358 2806 ...
result:
ok OK (n = 10000, m = 200000)
Test #25:
score: 0
Accepted
time: 1080ms
memory: 44804kb
input:
10000 200000 8 3930 5634 5297 1113 2260 9235 6143 5777 9951 8103 5378 8844 4858 4701 1141 1266 9200 1752 2072 3094 6597 3169 5537 5214 5626 6444 7944 5343 237 1641 1505 6890 9613 3567 7027 1782 2566 7572 6830 5122 5618 2380 7375 6441 2493 3794 254 1264 1248 4256 4362 1100 1744 2290 4130 8407 1501 86...
output:
5806 6252 6315 6257 6984 3808 9045 8356 1639 2098 3095 7615 9620 5776 2076 1647 8985 6272 9948 4513 5251 851 674 3979 790 2451 5580 9294 8912 852 4209 3395 9243 2841 9957 2222 6221 3544 1485 8716 9824 6997 2324 5479 6635 8377 5096 318 1720 9753 4493 3887 4993 1411 6184 7678 9749 2936 2150 6439 7706 ...
result:
ok OK (n = 10000, m = 200000)
Test #26:
score: 0
Accepted
time: 1116ms
memory: 44028kb
input:
10000 200000 8 250 3672 9839 5668 7301 2079 8067 6342 9 4975 9607 2066 9155 1811 9941 3432 8551 629 4925 9987 5919 2483 1940 3439 5 8111 4342 3490 3374 7638 4223 2166 2363 6459 9739 743 1402 4217 6997 4834 4819 1666 9929 4646 6536 3713 3806 7080 7079 7011 5063 5627 2022 6762 1269 8085 1309 3380 5929...
output:
2192 5390 1834 104 6723 3918 1972 4772 3557 8922 1106 9860 7989 974 3405 8519 5010 5788 6959 133 1065 1148 9058 4658 9450 1112 5556 2276 7521 7556 2842 1062 1255 3203 4823 2330 4711 1869 2663 7362 5566 3125 9749 9074 1850 9266 6957 8193 7293 7889 5957 3670 2175 1250 5537 6325 5647 3332 1143 7786 960...
result:
ok OK (n = 10000, m = 200000)
Test #27:
score: 0
Accepted
time: 1047ms
memory: 44280kb
input:
10000 200000 8 3302 6417 9413 9399 3313 4131 786 2293 9139 9699 8443 4561 9691 5227 464 4981 7873 7640 3846 819 4065 1347 1636 278 581 470 1146 6526 6905 220 2531 1990 5091 8710 1122 57 3891 6774 6722 1119 1982 5076 4842 5563 1517 4655 9328 8119 273 6638 6329 6210 6476 8054 2405 1312 1326 703 8278 3...
output:
4050 8242 5233 4895 1722 1648 2825 7461 5597 2525 4305 6240 2337 6042 5375 7941 6181 3539 3906 5813 9800 3876 9900 1933 5931 4802 7841 8467 2824 5915 9534 1718 5171 9702 7536 9936 2758 7547 302 469 882 3465 7419 2775 7814 494 1202 3182 9529 3632 5577 6360 2529 3888 7621 7756 5085 1626 3082 4420 871 ...
result:
ok OK (n = 10000, m = 200000)
Test #28:
score: 0
Accepted
time: 1056ms
memory: 43752kb
input:
10000 200000 8 3084 3869 4018 2306 296 5389 4299 3629 7339 2276 1885 6331 6469 4950 2711 5913 7166 2786 8833 5589 1036 9761 9475 904 7264 2290 6037 5553 8538 3088 5159 1113 9688 3643 3759 1510 4493 9454 1740 6427 8322 5352 357 5133 2320 9267 9060 6912 9835 147 5047 6007 7724 4978 5151 1971 4181 376 ...
output:
5945 1202 3076 5116 5988 462 3403 4700 6117 2329 9432 938 8458 4704 2592 8656 2496 5304 1609 3838 2106 5619 4553 8401 3254 6027 8029 4506 9787 2365 4282 4768 4713 934 1648 4781 9911 7649 1313 6001 4699 5279 8062 2074 3250 5665 1217 6194 8305 6198 3100 5426 2787 7423 8437 4898 8467 155 1229 6161 606 ...
result:
ok OK (n = 10000, m = 200000)
Test #29:
score: 0
Accepted
time: 1044ms
memory: 43860kb
input:
10000 200000 8 9597 6028 3656 4390 8250 5855 8607 352 4611 2706 9934 7374 9486 979 6681 6227 6429 6067 9887 4297 6831 7725 5456 5316 54 3573 9016 570 8272 6242 2109 9535 6155 1258 7653 5102 3208 2257 2051 757 3836 2495 6474 3355 8945 7549 3001 3458 5766 7537 1216 5016 5767 7532 9508 62 9873 2398 673...
output:
2906 5801 3634 2644 4669 3439 4992 7585 7753 5344 8059 4417 608 5017 8289 9752 4337 8744 6690 2198 2669 823 6596 9813 3286 9372 5689 9128 4451 8023 1852 9883 4626 2856 389 8020 5164 8980 1378 3305 4730 6252 859 8198 690 6387 5891 2921 9200 1292 1783 308 2363 9176 2210 4338 1470 6645 2203 1962 4175 5...
result:
ok OK (n = 10000, m = 200000)
Test #30:
score: 0
Accepted
time: 1093ms
memory: 45764kb
input:
10000 200000 8 2841 2895 8325 5650 7175 5527 3709 2461 954 989 2590 7692 8743 3316 2375 5924 5663 7482 7008 6944 1452 5240 9580 3515 8952 4318 82 1578 6108 9683 3380 7256 4492 1555 2801 833 37 5183 7656 4109 8526 6505 3193 228 1390 9500 1152 7758 8065 8808 4837 3239 605 5717 5475 5585 8403 6770 2849...
output:
1 7745 8654 1321 627 3970 2424 6318 1059 8084 2864 3918 7777 4247 1271 8895 7956 5270 7715 6622 7107 2958 9872 2841 3718 1073 1799 4381 2304 2613 2464 3079 6994 8129 2055 5282 9364 1620 7556 3679 4222 2819 175 1066 8108 893 373 3816 349 4774 8953 8475 6493 3225 9441 4348 6114 4454 9252 8226 1049 592...
result:
ok OK (n = 10000, m = 200000)
Test #31:
score: 0
Accepted
time: 1094ms
memory: 43336kb
input:
10000 200000 8 2816 4469 8026 6086 7071 4407 9605 9956 6368 7125 9853 7284 4241 1959 9793 5004 4867 7032 196 3530 4897 2305 1847 5501 3957 4526 9236 8577 2046 3410 8972 4276 4699 4534 9206 8703 4979 8232 8553 6484 2391 7381 513 5754 9656 5122 3511 9811 6734 3960 5908 674 2236 9534 3053 8540 9771 349...
output:
597 4413 4638 7781 2355 7889 3271 9067 3410 5363 6102 734 7795 2019 5276 6977 9759 4871 125 1265 2600 3248 1574 2066 6179 2922 3562 9122 6893 3713 2722 7160 675 1353 1631 6446 6818 3965 5479 2996 929 8160 1459 1366 2933 7389 6533 2189 1700 2291 80 515 7765 3354 72 9647 7859 7108 5324 2689 9535 8151 ...
result:
ok OK (n = 10000, m = 200000)
Extra Test:
score: 0
Extra Test Passed