QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#870016 | #8618. Have You Seen This Subarray? | ucup-team5008# | ML | 988ms | 486260kb | C++20 | 3.6kb | 2025-01-25 14:26:07 | 2025-01-25 14:26:31 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define rep2(i,j,k) for(ll i=ll(j); i<ll(k); i++)
#define rep(i,j) rep2(i,0,j)
#define rrep2(i,j,k) for(ll i=ll(j)-1;i>=ll(k);i--)
#define rrep(i,j) rrep2(i,j,0)
#define SZ(a) ll(a.size())
#define all(a) a.begin(),a.end()
#define eb emplace_back
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using vp=vector<P>;
using vvp=vector<vp>;
const ll inf=LLONG_MAX/4;
template<typename T>
bool chmin(T& a,T b){return a>b?a=b,1:0;}
template<typename T>
bool chmax(T& a,T b){return a<b?a=b,1:0;}
void n_large(ll n,ll m,ll q){
vvp query(n);
vl a(n);
rep(i,n) a[i]=i;
rep(i,m){
ll x,y;cin>>x>>y;
--x,--y;
query[a[x]].eb(i,y);
query[a[y]].eb(i,x);
swap(a[x],a[y]);
}
while(q--){
ll k;cin>>k;
vl b(k);
vl curr(k);
rep(i,k) cin>>b[i], --b[i], curr[i]=b[i];
vector<tuple<ll,ll,ll>> c;
rep(i,k){
for(auto el2:query[b[i]]) c.eb(el2.first,i,el2.second);
}
sort(all(c));
ll ans=-1;
ll last=-1;
ll cnt=0;
rep(i,k){
if(curr[i]==curr[0]+i) cnt++;
}
for(auto [idx,i,j]: c){
if(last != idx){
if(cnt==k){
ans=last;
break;
}
}
if(curr[i]==curr[0]+i) cnt--;
curr[i]=j;
if(curr[i]==curr[0]+i) cnt++;
if(i==0){
cnt=0;
rep(f,k){
if(curr[f]==curr[0]+f) cnt++;
}
}
last=idx;
}
if(ans==-1) ans=last;
ans++;
cout<<ans<<"\n";
}
}
struct state {
std::unordered_map<int, int> to;
int len, link, ind;
};
struct suffix_automaton {
std::vector<state> sa;
int last, size;
void init() {
sa.clear();
sa.push_back(state());
sa[0].len = 0;
sa[0].link = -1;
last = 0;
size = 1;
}
suffix_automaton() {
init();
}
int add_c(int c, int ind) {
int cur = last;
sa.push_back(state());
int added_id = size++;
last = added_id;
sa[last].len = sa[cur].len + 1;
sa[last].ind = ind;
do {
sa[cur].to[c] = last;
cur = sa[cur].link;
} while (cur != -1 && !sa[cur].to.count(c));
if (cur == -1) sa[last].link = 0;
else if (sa[sa[cur].to[c]].len == sa[cur].len + 1) sa[last].link = sa[cur].to[c];
else {
int k = sa[cur].to[c];
sa.push_back(sa[k]);
sa[size].to = std::unordered_map<int, int>(sa[k].to);
sa[size].len = sa[cur].len + 1;
sa[size].ind = ~(1 << 31);
sa[last].link = sa[k].link = size;
do {
sa[cur].to[c] = size;
cur = sa[cur].link;
} while (cur != -1 && sa[cur].to[c] == k);
++size;
}
return added_id;
}
};
void n_small(int n, int m, int q) {
vector<int> now(n);
iota(all(now), 0);
vector<int> v = now;
rep(i,m){
ll x,y;cin>>x>>y;
--x,--y;
swap(now[x], now[y]);
v.eb(n + 1);
v.insert(v.end(), all(now));
}
suffix_automaton au;
int ind = 0;
for (int i = 0; i < (int)v.size(); ++i) {
au.add_c(v[i], ind);
if (v[i] == n + 1) ++ind;
}
printf("\n");
std::vector<std::pair<int, int> > ord(au.size);
for (int i = 0; i < au.size; ++i) ord[i] = std::make_pair(au.sa[i].len, i);
std::sort(ord.begin(), ord.end());
for (int i = ord.size() - 1; i > 0; --i) {
int id = ord[i].second;
au.sa[au.sa[id].link].ind = std::min(au.sa[au.sa[id].link].ind, au.sa[id].ind);
}
while(q--) {
int k;
cin >> k;
vector<int> b(k);
rep(i, k) cin >> b[i], --b[i];
int cur = 0;
bool ok = 1;
for (int i = 0; i < (int)b.size() && ok; ++i) cur = au.sa[cur].to[b[i]];
printf("%d\n", au.sa[cur].ind);
}
}
int main(){
/*
suffix_automaton au;
char s[10];
scanf("%s", s);
for (int i = 0; s[i]; ++i) au.add_c(s[i] - 'a');
int diff = 0;
for (int i = 1; i < au.size; ++i) diff += au.sa[i].len - au.sa[au.sa[i].link].len;
printf("%d\n", diff);
return 0;
*/
cin.tie(0)->sync_with_stdio(0);
int n,m,q;
cin >> n >> m >> q;
if(n <= 300) n_small(n,m,q);
else n_large(n,m,q);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3840kb
input:
6 3 5 1 5 3 4 1 6 2 4 1 3 3 1 5 3 3 4 5 4 5 2 4 3 2 6 2
output:
1 3 0 2 3
result:
ok 5 number(s): "1 3 0 2 3"
Test #2:
score: 0
Accepted
time: 0ms
memory: 4704kb
input:
50 50 16 21 30 14 39 5 32 31 48 38 50 40 49 14 33 32 42 7 15 5 25 24 28 8 10 18 24 5 39 4 37 9 28 29 39 2 35 11 32 48 49 12 17 38 44 26 33 12 40 19 49 40 41 17 18 20 30 11 15 21 36 37 38 7 48 17 21 8 38 30 34 3 31 7 12 31 47 2 37 20 41 13 40 33 39 10 49 19 40 12 30 23 28 9 45 27 32 4 37 27 29 2 44 4...
output:
0 29 44 22 23 18 1 37 3 16 0 16 0 13 0 0
result:
ok 16 numbers
Test #3:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
500 500 165 5 424 246 385 355 428 43 338 214 378 286 469 6 467 149 333 203 411 7 111 395 483 256 288 69 414 33 429 159 425 22 470 13 425 235 292 291 412 76 224 64 207 198 365 268 314 116 366 338 386 58 265 328 330 146 493 89 288 120 465 187 201 336 499 406 485 195 406 56 485 410 424 125 149 154 216 ...
output:
68 77 385 0 391 119 0 443 216 0 0 420 0 136 434 0 163 77 410 122 0 0 436 474 285 0 109 89 13 0 38 0 0 133 48 390 0 0 157 25 402 0 232 272 0 0 374 294 226 0 16 0 151 295 80 17 184 379 333 199 431 0 0 0 10 0 0 0 357 431 165 0 0 408 296 0 0 0 191 0 275 233 184 284 0 107 0 213 193 317 0 0 349 311 82 0 1...
result:
ok 165 numbers
Test #4:
score: 0
Accepted
time: 1ms
memory: 4224kb
input:
5000 5000 188 121 3352 1927 3462 1474 2956 818 3688 2965 3432 2063 2891 946 2028 2270 3486 1809 2413 108 4387 920 4467 198 2766 2950 4940 1447 1580 4703 4722 1285 1768 94 1205 1863 4496 908 4980 2181 3000 1508 3798 2161 4451 952 3285 339 1166 291 3872 3014 4857 1999 2809 2892 4392 1994 3280 557 3600...
output:
619 2857 3580 3942 3094 189 0 3024 3750 3954 51 3815 1731 150 3082 4683 4303 2289 153 629 1512 1245 1028 4033 1158 1279 3758 1929 3077 2317 4291 632 2855 1513 526 1047 675 278 498 1535 2549 2361 3393 4438 458 1618 158 3991 2120 3290 2469 2357 3152 3166 206 2279 2352 3077 4786 0 2682 2822 2598 3157 4...
result:
ok 188 numbers
Test #5:
score: 0
Accepted
time: 35ms
memory: 11748kb
input:
100000 100000 33297 71020 88781 73567 91865 28411 98582 30528 55399 32377 88782 5464 33315 16441 21471 13984 59425 4953 40519 24887 54173 42736 94259 36960 89613 25476 27783 95468 96479 72650 76406 8812 58175 71657 81205 24702 49487 50388 67643 6272 23503 25087 72725 48821 81737 30758 71554 55829 82...
output:
27228 22301 7931 0 75416 1215 0 25576 22641 0 0 17383 24756 30126 15021 32805 65792 88809 22668 0 0 0 0 9889 0 53443 65387 0 80361 74814 86721 0 0 63844 0 33458 19889 75869 79460 33108 72549 68381 3025 0 0 25883 20179 55587 47021 84515 0 33494 15631 0 62931 0 53663 44093 21837 40160 26104 55703 0 0 ...
result:
ok 33297 numbers
Test #6:
score: 0
Accepted
time: 43ms
memory: 11692kb
input:
100000 100000 100000 36004 87861 86753 97164 50337 64104 57483 58920 50782 94040 66749 76405 46667 79515 1545 97049 54733 71517 7919 97284 18761 54240 26599 48474 5122 10540 21254 35983 81511 98419 30413 67662 38448 47203 25866 55510 85602 98353 62852 77724 27306 66940 35955 53948 4223 91729 90149 9...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 100000 numbers
Test #7:
score: 0
Accepted
time: 36ms
memory: 11748kb
input:
100000 100000 66652 22994 71513 10658 88662 1807 55418 66243 90922 42557 51157 47642 82097 523 1973 904 95794 3610 35213 47230 91500 20542 36216 33892 71053 29813 84930 16027 99750 15436 93166 90680 93515 36466 89585 15141 69056 81445 88916 9101 96490 13087 52198 21584 55609 32214 99179 72280 75437 ...
output:
20955 0 0 45077 0 0 0 0 29096 0 76005 0 0 0 11328 36753 0 41674 36156 446 65729 73462 19985 80899 0 0 0 0 0 60255 8012 0 0 0 0 0 0 28968 0 0 0 0 72218 21749 21058 0 0 0 0 0 0 0 0 24280 0 70613 14938 706 0 0 0 0 0 50017 0 0 0 0 32881 0 32413 0 0 0 0 0 0 52263 47541 0 0 0 6900 0 25846 0 91075 0 0 0 31...
result:
ok 66652 numbers
Test #8:
score: 0
Accepted
time: 39ms
memory: 11624kb
input:
100000 100000 49963 43461 76126 47999 69477 44427 55721 59597 99283 39193 60450 22213 29867 2229 68597 9589 71446 40976 68247 22820 50975 7041 44604 3521 4699 7165 34683 4692 53860 9816 36375 48431 75451 81851 83086 46691 98255 18820 28625 24245 25659 41073 41314 3832 27757 311 49980 8518 88906 1357...
output:
0 5213 0 0 8053 0 0 45209 0 0 44776 40506 46845 0 0 5860 70896 53576 0 854 82107 64134 0 14000 74001 75741 0 11040 688 86138 0 32383 2853 0 50735 0 9101 60076 0 71516 16291 0 0 0 0 0 9763 0 66272 68734 55387 0 0 78727 74088 39997 77565 27790 1605 23307 0 14682 4028 0 50364 43525 0 55936 49424 0 0 18...
result:
ok 49963 numbers
Test #9:
score: 0
Accepted
time: 35ms
memory: 11744kb
input:
100000 100000 18171 29975 72983 27998 93792 31466 82309 25911 66592 20873 50102 20462 54015 24423 32334 5133 50011 43400 83486 16333 32326 19998 49819 71405 85315 23961 31574 10103 82146 72621 84128 385 61995 310 52367 48257 96081 809 62537 19925 32177 64047 67534 11395 56798 58344 84094 31549 41454...
output:
83824 51294 42396 92956 35315 67672 47179 343 68909 36368 46810 0 33146 25662 20050 23849 0 80208 32083 24689 32840 31079 0 22672 72093 58449 71720 66396 0 71934 20351 91870 93940 41146 24156 68412 68143 0 0 87635 13275 25041 76654 273 81223 0 48926 85929 20349 0 0 3580 2644 0 0 75015 0 0 79336 1681...
result:
ok 18171 numbers
Test #10:
score: 0
Accepted
time: 36ms
memory: 11748kb
input:
100000 100000 6487 93520 95421 30400 62615 1951 83044 41508 90660 1054 38886 4410 70952 23586 96134 83162 99696 26056 47278 17385 61522 13151 87077 9702 90491 55848 82789 15155 33232 45308 89328 54038 61545 9064 26596 20886 86998 19381 65034 54688 79551 11399 77613 17246 82848 44061 65570 9277 73507...
output:
64646 30752 91838 37452 23440 12218 69492 9116 75189 47656 95622 41319 81011 89043 3241 0 1655 33466 81215 85138 78911 92874 89477 73931 26452 21062 65934 36286 59326 28218 29161 25810 66231 39536 6230 33282 20653 39301 8073 25201 56576 27448 73012 58079 66056 20236 2206 87061 47518 67303 47739 3582...
result:
ok 6487 numbers
Test #11:
score: 0
Accepted
time: 34ms
memory: 11744kb
input:
100000 100000 3889 6824 44272 7953 41679 29247 64748 5425 73326 32362 88465 14595 70806 84748 97666 69225 77398 23271 89456 18658 33389 26780 83361 35947 83442 6060 78512 50609 57165 31689 79799 7399 71009 15270 40950 7430 92031 17748 48465 20574 54533 1288 78339 77760 88430 36507 74792 31913 88932 ...
output:
65300 75771 19231 34178 40370 72287 90877 42868 21467 31341 51475 21343 52313 91168 33439 89080 72625 15933 51344 40373 34077 9127 29975 13775 69999 33074 66730 98063 8899 73371 32439 31006 17512 57102 75372 19924 20162 21255 69600 60251 63709 48469 13325 55157 90346 14062 10948 88667 36935 10701 77...
result:
ok 3889 numbers
Test #12:
score: 0
Accepted
time: 34ms
memory: 11748kb
input:
100000 100000 400 71199 87490 36484 68533 37117 96109 8848 11256 35636 71230 57301 89083 20202 46774 1507 34537 9117 19504 27635 29289 26556 44606 33824 43277 5345 73653 37056 62505 75807 92210 18624 33223 47357 63627 87341 90506 39869 80288 5008 38702 88801 92572 54411 59816 1793 49615 71877 97192 ...
output:
99141 74030 16619 70001 122 35866 70327 37180 99948 44225 33741 14762 20348 17090 88645 89807 16903 50325 54567 54552 94568 61923 90159 26930 87056 97065 74629 38296 19856 29905 46778 81118 81348 10596 75198 70997 17924 26919 66336 53096 1591 22405 2662 60054 48584 61277 18796 5556 53414 81701 10433...
result:
ok 400 numbers
Test #13:
score: 0
Accepted
time: 39ms
memory: 12380kb
input:
100000 100000 40 33812 48349 15097 43656 11978 68493 249 51825 43291 91166 34578 58910 31288 67968 41380 56661 57983 89330 16836 66476 39948 42282 65903 96817 10348 67447 26333 96853 72576 98956 35688 85978 49893 79139 16834 70393 47175 84119 1447 69694 13724 14867 24711 26687 27980 63923 8319 99848...
output:
78906 85062 14765 9789 79202 44840 62646 62651 7566 56152 89337 56379 92388 26469 25562 13601 59429 90892 49043 8594 19156 19762 58826 69226 51258 86571 61661 30687 36329 87695 76536 70333 98284 6598 59312 37819 29386 71881 51876 99729
result:
ok 40 numbers
Test #14:
score: 0
Accepted
time: 40ms
memory: 21760kb
input:
100000 100000 2 28131 28197 25868 68332 78570 86410 77755 90610 12794 89014 46353 51255 30636 64496 68207 88651 17370 20173 22246 32963 23578 51745 11675 93581 49024 95047 1413 72087 9613 93622 40678 89451 34298 87112 8737 53341 25639 41997 17205 75200 67586 74870 453 36247 51730 94593 23501 83101 5...
output:
16948 11551
result:
ok 2 number(s): "16948 11551"
Test #15:
score: 0
Accepted
time: 57ms
memory: 80216kb
input:
2 100000 66664 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1...
output:
0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0 0 1 0 1 0 1 0 0 1 1 0 0 1 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 1 0 1 1 0...
result:
ok 66664 numbers
Test #16:
score: 0
Accepted
time: 214ms
memory: 160584kb
input:
3 100000 49970 2 3 2 3 2 3 1 3 2 3 2 3 1 3 1 3 1 3 1 2 2 3 1 3 1 3 2 3 2 3 1 3 2 3 2 3 1 3 1 2 2 3 1 3 2 3 2 3 1 3 1 3 1 2 1 3 2 3 1 2 1 2 1 3 1 2 1 3 1 3 1 3 1 3 2 3 2 3 1 3 1 3 1 2 1 3 2 3 1 3 1 3 1 2 1 2 1 3 1 2 2 3 1 2 1 2 2 3 1 2 2 3 1 3 2 3 2 3 2 3 1 2 1 2 1 2 2 3 1 2 2 3 2 3 2 3 2 3 1 2 1 2 1...
output:
10 0 0 4 0 10 5 0 0 1 0 4 5 10 0 0 1 5 0 5 4 4 5 10 0 0 5 0 1 0 0 1 11 5 0 1 1 1 5 1 5 0 5 0 1 0 1 0 4 4 4 0 4 0 0 5 1 0 0 0 1 0 0 11 1 0 0 0 0 0 0 1 5 5 5 0 0 1 0 0 1 0 0 0 0 1 5 1 11 0 1 1 0 1 5 0 11 0 4 5 10 0 0 0 0 5 1 0 10 0 10 4 0 0 0 11 5 1 0 0 4 10 1 4 4 0 1 4 0 0 5 4 10 4 1 4 0 0 10 11 0 4...
result:
ok 49970 numbers
Test #17:
score: 0
Accepted
time: 296ms
memory: 193256kb
input:
4 100000 40176 2 4 2 3 3 4 1 3 1 4 2 3 2 3 2 3 2 3 3 4 1 3 1 3 1 4 1 3 2 4 1 2 1 3 1 3 2 4 1 3 2 4 2 4 1 2 1 2 1 3 3 4 2 3 1 3 1 3 2 4 2 4 2 3 3 4 2 3 3 4 2 3 1 3 1 4 1 3 1 4 2 3 3 4 2 3 2 3 1 2 3 4 1 3 3 4 1 4 1 4 3 4 2 3 2 3 3 4 1 4 2 3 2 4 1 2 3 4 2 3 1 4 1 4 2 4 3 4 1 3 1 4 1 2 2 4 1 3 2 4 3 4 3...
output:
0 0 3 0 27 2 0 0 27 48 0 48 2 0 0 3 0 0 6 0 3 10 4 10 0 15 2 0 23 16 2 1 16 2 5 35 16 10 0 0 3 6 4 1 0 2 1 0 16 4 3 0 0 0 4 23 10 0 1 2 3 15 3 16 0 16 1 23 1 35 0 2 5 2 0 0 16 46 35 101 0 1 0 0 1 0 17 0 0 0 2 11 1 15 1 4 0 10 23 0 0 0 2 4 0 2 0 2 1 1 4 1 3 3 0 2 1 0 56 0 16 0 60 10 0 1 2 47 47 4 1 ...
result:
ok 40176 numbers
Test #18:
score: 0
Accepted
time: 367ms
memory: 226372kb
input:
5 100000 33362 2 5 3 5 2 5 3 5 1 5 2 5 1 4 2 3 1 4 1 2 2 3 1 3 2 3 2 3 1 5 1 3 1 4 4 5 3 5 2 3 3 4 3 4 1 4 1 2 3 5 1 4 1 3 4 5 2 5 2 5 1 4 1 2 2 4 1 2 2 3 4 5 4 5 3 4 2 4 2 5 3 4 1 4 1 4 3 4 3 4 1 4 2 4 2 4 1 2 2 4 2 4 3 4 2 3 1 3 1 5 4 5 1 5 1 3 2 3 4 5 2 4 3 5 2 5 1 5 1 2 2 5 1 3 4 5 1 5 1 5 3 5 3...
output:
0 0 0 0 0 195 102 132 8 78 0 0 17 0 0 101 9 3 0 182 0 0 0 0 9 21 0 47 0 84 6 0 16 0 15 0 0 11 0 29 102 1 1 9 153 6 11 0 155 0 9 81 3 170 210 4 47 0 31 0 36 5 103 3 68 38 0 1 0 15 11 128 89 25 57 94 1 121 3 1 1 0 3 4 94 9 0 89 28 130 121 25 0 17 2 187 57 3 0 0 336 53 9 47 210 17 25 0 3 2 15 0 0 3 0 ...
result:
ok 33362 numbers
Test #19:
score: 0
Accepted
time: 437ms
memory: 309428kb
input:
6 100000 28674 3 5 2 3 2 5 1 4 2 5 2 5 1 2 1 3 1 5 4 6 1 6 3 4 3 6 3 5 5 6 2 4 1 5 2 6 3 6 4 5 4 6 5 6 4 6 5 6 5 6 1 5 5 6 1 4 4 5 3 4 1 2 3 4 1 3 3 4 4 5 4 5 2 5 1 5 2 4 3 6 3 6 1 2 4 6 2 6 1 3 1 4 2 5 2 6 2 5 1 6 1 4 1 6 1 4 2 5 2 4 4 6 5 6 2 6 2 5 1 6 4 5 1 3 4 6 5 6 3 6 1 2 5 6 4 6 1 3 1 3 3 5 5...
output:
1595 0 206 61 0 0 15 345 0 0 7 176 364 30 22 0 0 1 0 7 0 826 0 14 0 111 1 179 310 0 617 64 1 0 5 14 0 81 44 8 12 94 53 0 11 248 340 80 9 29 40 483 0 106 5 626 9 0 0 244 43 0 884 0 390 46 2 594 125 310 145 344 268 1807 544 126 1075 256 1413 1476 10 581 3646 263 45 0 0 840 75 216 2 8 705 162 2 0 1568...
result:
ok 28674 numbers
Test #20:
score: 0
Accepted
time: 600ms
memory: 315376kb
input:
7 100000 24903 2 6 2 4 1 5 6 7 4 6 3 4 2 6 1 5 2 3 1 3 3 6 3 7 1 2 3 5 1 2 2 3 1 2 1 2 4 6 5 6 2 7 3 7 4 5 2 5 2 6 1 6 5 6 5 7 4 7 1 6 1 5 2 6 1 7 1 5 4 6 5 7 1 4 1 7 2 4 4 5 2 3 3 7 5 6 1 3 2 3 5 6 4 6 2 5 1 4 1 7 5 6 1 5 2 7 1 5 1 7 3 5 2 6 4 6 2 7 4 6 4 7 5 6 2 5 5 7 2 5 2 5 3 4 2 5 4 7 1 5 1 3 1...
output:
4 90 1 0 339 257 85 208 0 293 86 426 21 6549 1289 9 769 4593 5 232 71 6 1423 2 690 52 299 4022 72 27 4017 2261 15 4798 9726 801 380 1733 289 35 0 1 427 386 1778 359 0 24 0 152 3 3239 820 528 35 1613 159 77 235 3 1180 257 4460 1116 107 3 1538 23 0 48 20 94 0 1444 199 1508 8611 1 585 9252 86 707 2539...
result:
ok 24903 numbers
Test #21:
score: 0
Accepted
time: 782ms
memory: 361244kb
input:
8 100000 22189 3 7 1 4 1 2 5 7 3 4 2 5 6 7 2 4 4 8 7 8 3 4 2 8 1 4 4 8 6 7 4 5 1 4 3 5 1 3 2 5 1 5 3 8 7 8 5 6 4 6 1 2 3 8 5 7 5 6 1 4 1 8 6 7 2 6 4 8 1 4 2 7 3 4 3 5 5 6 4 7 4 6 5 6 1 5 3 6 3 5 6 7 2 8 2 8 6 8 2 4 5 6 1 7 1 8 1 4 3 8 3 7 3 6 2 5 6 7 2 6 3 7 1 5 4 7 3 4 1 3 1 3 2 6 5 7 3 8 3 6 3 8 1...
output:
2165 354 27879 16617 0 0 2 1112 13859 22 13681 12676 27 1942 8954 5651 0 11 3833 4379 146 0 54123 46302 214 526 0 2218 498 13114 42412 0 172 17541 5798 20 255 80 9683 490 1612 326 1939 1846 161 31255 2963 6479 15 26689 124 223 45 22 7848 0 5 16182 2813 125 16588 5694 18 15 1340 27344 10651 4019 491...
result:
ok 22189 numbers
Test #22:
score: 0
Accepted
time: 848ms
memory: 388328kb
input:
9 100000 19914 2 7 4 6 1 8 3 9 2 3 1 9 3 6 3 4 6 8 4 9 2 4 4 8 3 5 3 9 6 9 6 8 4 9 6 8 3 4 2 6 3 4 1 4 5 8 5 6 2 9 4 9 1 8 7 8 2 6 1 9 1 6 3 9 4 5 2 3 2 6 6 9 1 6 1 4 1 3 6 8 8 9 2 8 2 3 3 8 1 7 1 5 1 5 2 8 3 6 4 5 3 7 4 6 3 9 2 9 1 6 5 8 6 9 6 7 1 8 2 8 1 4 1 2 1 3 1 9 3 5 4 7 6 7 4 5 3 8 3 6 1 7 4...
output:
6537 51166 0 31871 81318 0 0 42 68269 462 28510 0 21597 385 10 1569 19425 30875 92390 3280 6630 7 14 1203 54522 3037 36 0 80092 23581 4438 112 9926 40735 0 19230 12135 30944 15 4504 79878 54298 110 4979 30613 6 1224 9753 5042 22 846 425 2767 0 65975 7283 42 143 0 0 23053 98603 465 3666 36 9919 232 ...
result:
ok 19914 numbers
Test #23:
score: 0
Accepted
time: 905ms
memory: 416804kb
input:
10 100000 18183 3 8 6 8 5 6 9 10 1 3 4 5 4 10 5 7 4 9 5 10 3 8 2 7 4 8 2 5 1 10 2 10 4 5 2 6 1 3 2 4 7 9 1 3 1 7 5 9 5 9 4 6 2 8 1 4 1 2 2 5 4 7 1 5 5 6 7 9 3 5 4 10 4 9 3 7 3 6 1 9 5 10 2 4 6 10 4 9 7 9 8 9 7 8 1 7 8 10 1 3 4 8 8 9 2 8 3 6 5 7 6 9 8 10 1 4 8 9 2 4 1 2 8 10 4 7 5 8 1 4 2 9 5 9 6 7 3...
output:
52116 54043 0 44676 70167 95 32694 24362 39 1604 279 95730 13362 83914 8037 89202 32 34 25619 688 2812 39639 703 13517 3404 69216 69801 59832 74835 9755 4004 87 128 40676 116 44313 0 0 24143 276 1215 18932 11407 129 17 8 324 18811 66 60401 99647 3520 1841 1209 17488 218 734 71976 0 0 64209 2589 363...
result:
ok 18183 numbers
Test #24:
score: 0
Accepted
time: 907ms
memory: 451472kb
input:
11 100000 16679 6 7 8 10 7 8 6 11 2 3 6 8 3 6 3 5 1 6 3 9 1 10 1 9 3 8 3 9 6 8 3 5 2 11 3 11 1 5 4 8 9 10 10 11 3 10 1 7 2 7 4 6 1 3 6 11 3 5 2 3 5 10 1 6 3 6 1 10 1 9 4 9 5 9 2 10 4 9 3 4 8 10 8 9 2 7 1 2 1 6 2 11 4 11 2 7 1 10 1 5 3 8 9 11 8 9 7 11 1 2 10 11 3 5 4 10 5 7 8 9 7 9 8 10 7 8 7 9 2 3 3...
output:
9235 3897 49565 349 27467 7050 84832 0 3 9856 46 1804 67600 14508 97806 18285 2773 11474 16977 10178 4846 10416 18 2826 163 48902 72961 74672 7728 23104 61208 74381 36649 38740 85601 79943 22843 59620 44146 80437 30968 89350 80600 0 890 67476 4 50584 10673 50 67850 82334 332 32230 594 41478 79411 1...
result:
ok 16679 numbers
Test #25:
score: 0
Accepted
time: 988ms
memory: 486260kb
input:
12 100000 15444 2 4 4 12 7 10 8 9 2 12 8 12 9 10 5 11 6 11 1 3 4 8 3 4 4 5 3 7 6 12 2 6 10 12 4 11 5 6 3 4 3 8 1 4 1 9 2 11 3 11 8 11 4 8 10 11 1 11 6 12 6 11 9 11 2 7 3 9 6 7 1 7 4 11 11 12 4 11 2 11 2 11 2 8 6 8 1 6 1 7 5 9 4 11 10 11 1 6 8 10 5 6 1 8 3 10 1 6 4 11 6 11 7 8 6 12 1 12 3 7 9 10 7 10...
output:
1390 24796 28505 71150 71039 55476 68705 18717 6335 11 28803 0 48132 23755 22406 35401 28966 18262 59539 9389 1175 0 27144 0 64121 81978 46081 53302 20875 235 36551 728 0 40551 86352 5663 22534 0 0 20630 252 9620 99736 79777 6326 23267 35076 88039 138 3722 268 104 49747 88 0 0 12 52284 54069 33257 ...
result:
ok 15444 numbers
Test #26:
score: -100
Memory Limit Exceeded
input:
13 100000 14252 5 11 4 12 10 13 4 6 6 8 7 9 2 13 6 8 1 13 1 3 1 10 6 7 1 12 1 3 1 5 6 9 7 9 5 12 7 12 7 13 10 13 1 8 7 12 7 9 8 10 3 9 6 12 2 8 5 11 5 10 7 9 4 8 7 12 6 9 1 9 10 11 7 10 6 13 1 10 1 5 8 13 11 12 2 9 8 12 2 8 2 12 4 6 1 2 2 13 3 5 7 13 5 9 1 11 2 8 4 8 7 9 3 5 9 12 2 13 4 5 7 9 2 4 3 ...
output:
81519 60750 40469 33999 30851 87838 36252 23554 0 1 11386 0 27521 35 0 44146 97710 31335 59690 98473 52811 61087 568 0 76849 0 22719 37830 59360 407 97 6743 2027 60615 36379 88597 9 23 53562 98593 48478 335 1 72389 20232 25834 59989 68 0 142 6800 61978 7627 539 51680 48362 591 63118 86654 76151 300...