QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#701761#93. ConfusionTheZoneAC ✓372ms65824kbC++207.9kb2024-11-02 14:40:522024-11-02 14:40:56

Judging History

你现在查看的是最新测评结果

  • [2024-11-02 14:40:56]
  • 评测
  • 测评结果:AC
  • 用时:372ms
  • 内存:65824kb
  • [2024-11-02 14:40:52]
  • 提交

answer

#pragma comment(linker, "/STACK:10000000")
#define _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_DEPRECATE

#include <cassert>
#include <cstdio>
#include <iostream>
#include <sstream>
#include <numeric>
#include <bitset>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <functional>
#include <cstring>
#include <ctime>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;


#define pb push_back
#define mp make_pair
#define e1 first
#define e2 second
#define sz size

const int maxn = 200 * 1000;
const long long maxlen = 2 * (long long)(maxn) * (long long)(maxn);

struct item 
{
	ll key, right;
	int prior;
	ll add, val;

	item * l, * r;
	item() { }
	item (ll key, int prior) : key(key), prior(prior), l(NULL), r(NULL), add(0), val(0) { }
};
typedef item * pitem;

void upd(pitem t)
{
	if (!t)
		return;
	if (t->l)
		t->l->add += t->add;
	if (t->r)
		t->r->add += t->add;
	t->val += t->add;
	t->add = 0;
}

void split (pitem t, ll key, pitem & l, pitem & r) 
{
	upd(t);
	if (!t)
		l = r = NULL;
	else if (key <= t->key)
		split (t->l, key, l, t->l),  r = t;
	else
		split (t->r, key, t->r, r),  l = t;
	//upd(t);
}

void merge (pitem & t, pitem l, pitem r) 
{
	upd(l); upd(r);
	if (!l || !r)
		t = l ? l : r;
	else if (l->prior > r->prior)
		merge (l->r, l->r, r),  t = l;
	else
		merge (r->l, l, r->l),  t = r;
	//upd(t);
}

ll get(pitem t, ll key)
{
	upd(t);
	if (key >= t->key && key <= t->right)
		return t->val;
	if (key < t->key)
		return get(t->l, key);
	return get(t->r, key);
}

ll ch_left(pitem t, ll new_key)
{
	upd(t);
	if (t->l)
		return ch_left(t->l, new_key);
	else
	{
		t->key = new_key;
		return t->val;
	}
}

ll upp_bound(pitem t, ll key)
{
	upd(t);
	if (key >= t->key && key <= t->right)
		return t->key;
	if (key < t->key)
		return upp_bound(t->l, key);
	return upp_bound(t->r, key);
}

void add(pitem& t, ll x, ll del)
{
	static pitem l, r;
	l = r = NULL;
	ll k = upp_bound(t, x);
	assert(k <= x);
	split(t, k, l, r);
	if (k != x)
	{
		ll v = ch_left(r, x);
		pitem ne = new item(k, rand());
		ne->val = v;
		ne->right = x - 1;
		merge(l, l, ne);
	}
	r->add += del;
	merge(t, l, r);
}

int N, T, B, Q;
map< int, vector< pair< ll, ll > > > box[maxn];
map< int, int> sum[maxn];
int sumAll[maxn];
ll Max[maxn];
pitem root[maxn];


int main ()
{	
	scanf("%d%d\n", &N, &T);
	scanf("%d\n", &B);
	for (int i = 0; i < B; ++i)
	{
		int k, c;
		scanf("%d", &k);
		for (int j = 0; j < k; ++j)
		{
			scanf("%d", &c);c--;
			box[i][c].pb(mp(j, j));
			sum[i][c] += 1;
			sumAll[i]++;
			Max[i]++;
		}
		
		root[i] = new item(0, rand());
		root[i]->right = maxlen;
	}
	
	scanf("%d\n", &Q);
	
	int c, f, t, h, p;
	for (int i = 0; i < Q; ++i)
	{
		scanf("%d", &c);
		if (c == 1)
		{
			scanf("%d%d\n", &p, &f);
			f--;p--;
			printf("%d\n", sum[f][p]);
		}
		else 
		{
			scanf("%d%d%d%d\n", &p, &f, &h, &t);
			f--;t--;p--;
			
			int len = 0;
			while (!box[f][p].empty())
			{
 				ll b = box[f][p].back().e1, e = box[f][p].back().e2;
				b -= get(root[f], b); e -= get(root[f], e);
				
				if (b >= sumAll[f] - h)
				{
					len += e - b + 1;
					add(root[f], box[f][p].back().e2 + 1, e - b + 1);
					box[f][p].pop_back();
				}
				else 
				{
					int d = max( 0ll, e - (sumAll[f] - h) + 1 );
					len += d;
					if (d != 0) add(root[f], box[f][p].back().e2, d);
                    box[f][p].back().e2 -= d;
					break;
				}
			}
			
			sum[f][p] -= len;
			sumAll[f] -= len;
			
			sum[t][p] += len;
			sumAll[t] += len;
			
			if (len != 0)
			{
				box[t][p].pb(mp(Max[t], Max[t] + len - 1));
				Max[t] += len;
			}
		}
	}
	return 0;
}
/*#include <bits/stdc++.h>

using namespace std;
#define int long long
int seg[96069*4],lazy[96069*4];
void build(int p,int l,int r){
    seg[p] = lazy[p] = 0;
    if(l==r){
        return ;
    }
    int md = (l+r)/2;
    build(p*2,l,md);
    build(p*2+1,md+1,r);
}
void prop(int p,int l,int r){
    seg[p]+=lazy[p];
    if(l!=r){
        lazy[p*2]+=lazy[p];
        lazy[p*2+1]+=lazy[p];
    }
    lazy[p] = 0;
}
void update(int p,int l,int r,int lq,int rq,int val){
    prop(p,l,r);
    if(l>=lq&&r<=rq){
        lazy[p] = val;
        prop(p,l,r);
        return ;
    }
    if(r<lq||l>rq)return ;
    int md = (l+r)/2;
    update(p*2,l,md,lq,rq,val);
    update(p*2+1,md+1,r,lq,rq,val);
    seg[p] = min(seg[p*2],seg[p*2+1]);
}
multiset<int> co,vl,lo;
bool check(){
    if(co.size()<vl.size()){
        return 0;
    }
    auto it = vl.begin();
    for(auto i:co){
        if(it==vl.end())break;
        if((*it)<i){
            return 0;
        }
        it++;
    }
    return 1;
}
signed main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        int x[n],l[n],c[n],lol = -1;
        co.clear();vl.clear();lo.clear();
        map<int,int> sav;set<int> mp;
        int cnt= 0;
        for(int i = 0;i<n;i++){
            cin>>x[i];
        }
        for(int i = 0;i<n;i++){
            cin>>l[i];
            if(!l[i])lol = i;
        }
        for(int i = 0;i<n;i++){
            cin>>c[i];
            mp.insert(c[i]);
        }
        for(auto i:mp){
            sav[i] = ++cnt;
        }
        build(1,1,cnt);
        int le = 0;
        for(int i = 0;i<n;i++){
            if(l[i]){
                co.insert(c[i]);
                update(1,1,cnt,sav[c[i]],cnt,1);
            }else{
                vl.insert(c[i]);
                update(1,1,cnt,sav[c[i]],cnt,-1);
            }
            if(i<lol){
                cout<<-1<<" ";
                continue;

                le++;
            }
            if(le==0)cout<<-1<<" ";
            else cout<<x[i]+x[i]-x[le-1]<<" ";
        }
        cout<<endl;
    }
    return 0;
}
*/































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 76ms
memory: 58664kb

input:

99997 99992
99998
1 28325
0
2 54443 48261
1 1566
1 87812
1 41908
2 81203 8200
0
0
2 54310 67500
0
0
1 12359
3 49972 96817 24533
3 35064 27950 18193
0
0
0
5 39751 48171 66488 34607 88081
2 37672 13235
2 75769 90651
0
1 59266
0
1 99362
2 61753 91974
1 78591
2 34000 45622
2 26880 58629
0
2 57155 35231
...

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 50069 numbers

Test #2:

score: 0
Accepted
time: 187ms
memory: 34556kb

input:

99996 999
9
11165 874 597 953 636 217 863 767 93 376 841 684 934 824 836 858 520 265 18 627 72 69 178 705 898 589 819 12 929 365 494 987 562 182 583 10 724 137 10 50 375 341 316 9 678 117 817 560 940 168 999 779 319 386 23 387 419 698 915 146 177 251 635 411 692 557 588 788 108 704 835 225 292 558 6...

output:

13
9
12
10
10
6
10
6
11
14
13
10
12
7
11
10
11
12
10
13
8
8
12
10
11
11
7
16
10
8
10
13
8
10
7
18
11
6
13
13
9
13
12
12
5
12
9
6
16
16
8
9
8
9
13
10
9
10
14
11
13
8
13
14
9
7
12
8
13
10
11
6
7
11
9
15
17
10
10
7
12
13
4
12
13
17
11
11
13
10
15
5
13
11
7
10
9
9
10
7
9
13
15
4
7
7
10
14
11
19
11
12
9
...

result:

ok 50197 numbers

Test #3:

score: 0
Accepted
time: 186ms
memory: 33744kb

input:

99996 992
4
25176 574 962 898 93 66 856 390 747 505 91 460 927 729 991 746 543 27 91 318 276 62 10 967 875 709 716 394 117 372 226 462 295 150 341 160 251 154 559 528 686 210 768 690 608 274 379 383 631 759 886 209 604 798 142 874 508 328 448 110 328 284 401 900 117 677 680 25 637 560 782 573 157 59...

output:

21
27
31
21
28
20
25
24
27
27
28
29
21
25
19
24
31
28
35
24
25
33
30
25
20
32
28
23
21
29
27
24
25
24
20
34
31
28
25
20
25
17
27
28
25
14
8
26
22
21
28
23
15
31
21
18
28
17
23
24
21
18
28
17
29
27
22
30
27
26
16
26
31
21
31
34
21
32
29
26
18
19
19
25
20
28
20
28
34
18
23
26
17
33
33
34
25
28
28
26
2...

result:

ok 50029 numbers

Test #4:

score: 0
Accepted
time: 201ms
memory: 35112kb

input:

99993 991
3
33249 745 627 682 783 68 235 241 845 682 45 273 339 539 583 78 733 205 247 835 292 582 874 24 870 452 92 308 505 692 194 459 249 175 479 191 275 972 689 532 693 128 428 42 957 414 45 264 264 390 878 146 772 971 157 567 541 955 631 911 570 810 733 600 648 576 857 362 85 781 180 376 874 76...

output:

35
33
37
39
30
31
35
34
39
30
31
37
43
38
29
38
29
38
35
40
40
34
38
35
30
24
35
30
23
35
35
37
36
46
54
39
29
33
20
38
25
36
23
31
41
39
31
30
35
43
37
35
27
26
32
38
37
32
36
29
34
32
30
25
41
40
34
38
34
27
39
32
33
31
29
42
38
19
40
38
30
33
35
43
34
1
44
31
37
35
32
69
33
35
41
40
36
29
27
35
3...

result:

ok 49847 numbers

Test #5:

score: 0
Accepted
time: 201ms
memory: 35344kb

input:

99994 993
2
49856 989 352 640 82 87 845 797 640 788 66 968 645 380 399 257 517 673 55 288 642 234 302 291 661 623 853 233 70 289 408 607 905 969 862 848 293 234 375 488 227 175 112 170 349 675 529 652 470 874 738 390 852 310 61 470 885 679 542 362 132 253 247 523 472 674 874 674 39 134 634 390 166 6...

output:

52
55
48
40
48
47
54
59
49
46
50
58
43
46
46
56
44
53
46
62
5
58
52
51
47
64
52
46
52
57
55
46
52
53
51
48
59
57
38
50
48
46
57
53
53
49
43
45
42
57
60
43
37
46
51
68
47
56
54
57
11
51
44
44
61
40
59
45
51
52
49
45
43
47
49
44
61
45
39
44
51
54
49
42
47
52
54
43
51
50
47
79
38
43
42
74
51
43
49
61
5...

result:

ok 49896 numbers

Test #6:

score: 0
Accepted
time: 47ms
memory: 28740kb

input:

99992 998
1
99992 428 2 992 241 436 217 208 53 672 891 407 210 320 182 312 870 530 160 284 586 31 435 3 919 959 823 54 533 598 391 902 353 172 808 793 128 905 115 728 472 529 341 868 443 160 674 857 880 472 894 639 760 63 868 302 723 956 975 557 48 182 813 110 698 903 256 204 417 291 298 654 632 451...

output:

101
126
97
106
97
100
95
95
100
98
108
88
86
118
93
88
97
108
100
93
95
108
96
103
93
102
105
98
91
92
108
102
102
105
95
100
99
94
98
111
110
99
99
94
111
92
97
99
92
108
116
102
106
82
70
110
90
105
101
90
97
86
91
96
98
87
121
86
110
76
99
89
122
86
114
111
85
99
101
97
102
83
100
102
88
100
112
...

result:

ok 99997 numbers

Test #7:

score: 0
Accepted
time: 72ms
memory: 38660kb

input:

99999 1
997
114 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
111 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

96
121
105
83
101
96
93
110
92
99
81
102
102
109
109
95
97
185
95
107
84
105
89
116
116
116
107
96
101
95
67
87
75
98
99
96
90
72
103
104
99
84
99
102
116
114
93
102
96
101
109
109
95
103
110
49
117
106
99
101
111
69
106
85
90
109
82
113
84
48
9
104
107
87
95
106
105
109
102
100
97
109
91
101
87
119...

result:

ok 49808 numbers

Test #8:

score: 0
Accepted
time: 85ms
memory: 36920kb

input:

99995 2
999
92 2 1 1 1 1 1 2 1 2 1 1 2 2 1 2 1 2 2 1 2 2 2 1 1 1 2 1 1 2 1 2 2 1 1 1 2 1 1 1 2 2 2 1 1 2 1 2 1 1 2 1 2 1 2 1 1 2 2 2 2 2 1 2 1 1 1 2 2 2 2 2 2 1 1 1 2 2 2 1 1 2 2 1 2 1 1 2 1 2 2 2 1
106 1 2 2 2 1 2 1 1 2 1 2 2 2 2 1 1 1 1 2 2 1 1 1 1 1 1 2 2 1 2 2 2 1 2 2 1 2 2 1 2 2 1 2 1 1 1 2 2 2...

output:

39
40
44
49
48
51
38
44
65
42
64
44
47
46
63
56
47
48
60
48
41
58
50
52
60
38
56
49
52
50
41
67
65
58
33
42
64
47
60
47
48
42
50
51
48
48
60
57
42
45
55
52
50
44
42
46
54
44
51
49
45
53
51
47
42
62
53
43
45
44
39
38
85
54
56
51
38
64
44
54
37
58
41
50
43
46
50
53
52
42
55
49
47
56
37
47
71
45
38
50
...

result:

ok 49976 numbers

Test #9:

score: 0
Accepted
time: 88ms
memory: 36416kb

input:

99990 3
994
99 3 1 1 2 2 3 2 2 3 3 2 2 2 2 3 3 3 3 1 3 3 3 2 3 1 1 1 2 2 2 3 1 3 1 2 2 2 2 2 3 3 2 3 1 2 1 2 1 1 2 2 3 3 1 3 1 1 2 1 1 3 2 3 3 1 2 3 3 2 3 2 3 3 1 3 3 3 2 1 3 3 2 3 2 2 3 2 3 1 3 2 2 2 1 2 2 3 1 2
112 3 2 3 2 2 3 3 1 1 2 1 1 2 2 3 1 3 3 3 3 2 3 1 1 1 2 2 1 3 3 1 3 1 3 2 2 1 3 1 3 3 2...

output:

33
39
40
43
37
34
42
26
40
31
26
31
24
26
25
37
42
25
30
27
38
28
31
31
39
44
29
50
26
44
25
29
33
27
45
41
46
28
35
34
25
41
29
35
26
32
26
39
40
40
33
45
22
26
44
35
35
26
21
27
32
30
29
32
32
46
35
39
56
37
37
30
36
29
31
30
3
29
34
38
38
29
30
32
14
34
34
40
38
30
18
33
36
39
33
36
26
39
31
35
4...

result:

ok 49731 numbers

Test #10:

score: 0
Accepted
time: 86ms
memory: 36428kb

input:

99992 4
996
101 4 4 1 3 3 4 4 4 1 2 2 2 1 4 4 1 1 1 2 2 1 3 2 4 4 4 1 4 2 3 2 1 4 4 2 4 4 3 3 1 3 1 1 4 1 1 2 1 3 4 3 4 4 1 1 2 4 3 1 2 4 2 4 1 1 2 4 3 1 4 1 4 1 2 1 4 1 3 4 3 2 1 1 1 3 2 3 2 4 3 1 3 2 4 3 4 3 2 2 1 2
103 2 1 4 2 2 3 1 1 4 4 1 4 3 1 3 4 4 2 3 1 2 4 4 3 1 4 2 1 4 2 1 1 2 3 4 1 1 4 2 ...

output:

24
19
25
31
26
37
18
32
23
25
20
21
30
30
22
21
24
36
29
1
30
35
18
27
26
28
21
33
26
25
26
28
17
28
39
34
25
23
20
23
25
27
19
19
25
23
24
28
24
29
25
27
27
27
22
26
24
31
20
24
22
28
28
30
27
19
25
27
0
13
32
25
25
17
29
22
31
27
27
30
27
27
30
29
24
28
19
19
26
24
18
24
34
25
31
34
23
29
16
18
27...

result:

ok 49852 numbers

Test #11:

score: 0
Accepted
time: 103ms
memory: 36364kb

input:

99997 3
3
33297 2 3 1 3 3 1 1 2 3 1 2 3 3 2 2 2 1 2 2 2 3 2 2 3 3 1 2 2 3 2 1 1 1 2 2 2 3 3 1 3 3 1 1 1 1 1 1 2 1 3 3 3 3 3 1 1 2 2 3 2 2 3 2 2 1 3 1 1 1 3 2 2 3 1 2 1 1 1 1 1 1 1 1 2 3 1 2 1 2 1 2 1 2 2 3 1 3 2 3 3 1 1 2 2 3 2 2 1 3 1 3 1 3 1 3 3 3 3 1 2 2 1 2 3 3 3 2 1 2 2 2 2 1 3 1 1 2 1 2 1 2 1 ...

output:

11116
11116
8771
8771
10909
11270
11117
1586
1000
18893
538
1000
538
13632
20533
9418
23488
9418
18893
18980
18893
1000
13632
18980
6689
13632
13204
5408
14711
5408
1382
22345
5408
1382
3209
538
16076
12178
4403
14946
28503
14946
14946
18104
5408
15093
3965
4403
27477
3965
1586
538
27477
3965
328
15...

result:

ok 49852 numbers

Test #12:

score: 0
Accepted
time: 27ms
memory: 26068kb

input:

99996 4
1
99996 1 2 1 4 3 2 4 2 1 4 1 3 4 3 3 2 2 4 4 2 1 2 1 4 3 4 3 1 4 1 2 2 4 4 4 3 2 2 3 4 2 2 4 2 4 4 4 3 3 1 3 2 3 1 4 4 3 2 3 2 4 2 4 4 3 1 1 4 3 4 3 1 1 3 1 1 2 1 3 3 1 2 4 1 2 4 1 3 4 3 1 2 4 3 3 2 4 2 2 1 1 2 4 2 1 4 3 2 2 4 3 2 4 3 3 3 3 1 3 1 3 3 3 1 2 2 3 3 2 1 1 4 4 4 3 1 2 3 2 3 2 3 ...

output:

24938
25042
24933
25083
25042
24933
25083
25042
25042
25042
25083
25083
24933
24938
25042
25042
24938
25083
24933
24933
24938
25083
25042
25083
24933
25042
24933
24938
24933
25042
25083
25083
24933
24938
24938
25083
25042
25083
25083
24938
25083
24938
25042
25042
24933
24933
25042
25083
25042
25083
...

result:

ok 99998 numbers

Test #13:

score: 0
Accepted
time: 110ms
memory: 35704kb

input:

99990 4
5
19777 2 3 1 1 2 3 3 2 3 3 1 4 3 1 4 1 4 2 4 2 1 3 4 4 2 1 1 4 4 1 3 4 3 4 4 3 2 4 4 1 2 2 3 4 4 2 3 4 2 2 1 4 2 3 4 3 3 2 3 4 2 4 2 3 2 2 4 2 4 2 4 4 4 4 3 1 2 3 4 3 3 2 1 3 1 2 3 3 2 2 2 1 2 3 2 2 4 4 3 4 1 4 2 3 4 3 2 2 3 4 4 3 1 2 3 2 3 3 1 2 3 4 3 2 4 2 1 2 4 2 4 4 3 2 3 3 3 3 2 3 2 1 ...

output:

4896
4911
5061
5059
5049
4828
8617
5109
3274
9121
3019
8617
4893
321
8617
758
3274
386
4911
1920
386
4250
1920
4250
3274
386
8531
16612
1417
6874
1823
16612
465
15302
3274
6252
6195
321
15302
465
1534
6076
3886
6076
10431
2234
1092
12582
1570
3274
7886
12059
1570
6379
4101
63
752
116
19231
1574
3274...

result:

ok 50082 numbers

Test #14:

score: 0
Accepted
time: 116ms
memory: 36156kb

input:

99994 4
2
50173 4 1 1 2 1 3 4 1 4 3 2 4 2 3 4 2 3 3 4 4 3 2 1 3 3 3 1 3 2 4 2 4 4 2 2 4 3 3 3 2 1 3 4 1 2 4 2 1 4 3 4 1 2 4 3 4 1 1 3 1 4 3 4 3 3 4 1 1 3 4 1 3 3 4 1 3 1 2 3 1 4 2 2 3 4 2 4 2 1 4 2 3 3 3 4 3 3 1 3 3 1 4 4 1 1 1 4 1 2 3 2 4 1 2 3 2 3 1 3 3 3 3 4 1 1 3 2 2 2 3 2 2 2 1 2 2 4 2 1 4 1 1 ...

output:

12360
12615
8672
12407
8672
22205
12451
23346
19871
20125
23100
2049
19871
23100
4733
4733
2655
5256
19871
5256
2049
4733
4733
23346
19871
19871
2049
23346
2049
20125
23346
4733
11735
5256
23346
23346
20125
23100
19871
4733
7732
1514
24704
3545
21582
21582
21582
17516
23361
7342
24704
21582
21582
21...

result:

ok 50038 numbers

Test #15:

score: 0
Accepted
time: 96ms
memory: 56388kb

input:

99992 1
99997
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

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 25000 numbers

Test #16:

score: 0
Accepted
time: 89ms
memory: 55756kb

input:

99990 1
99990
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

output:

99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
99990
...

result:

ok 24999 numbers

Test #17:

score: 0
Accepted
time: 91ms
memory: 56596kb

input:

99996 1
99996
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

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 24999 numbers

Test #18:

score: 0
Accepted
time: 372ms
memory: 65824kb

input:

99998 99998
99995
99998 67027 7101 93343 81714 60039 19420 29485 60072 22857 43395 24491 92544 12836 70350 31032 90162 50020 38665 38419 95808 72983 74063 3683 46205 34620 64923 60192 11222 2926 45677 86032 18587 41453 91832 18321 59636 14478 82380 79316 23823 82999 86651 61207 12566 87372 21503 562...

output:

0
0

result:

ok 2 number(s): "0 0"

Test #19:

score: 0
Accepted
time: 361ms
memory: 65748kb

input:

99992 99992
99991
99992 98498 35519 29318 45672 70316 6721 46911 25728 21796 14061 36 58680 47947 48269 77145 83725 41120 70263 71453 11735 40971 6734 95340 59732 92362 33393 37094 60818 59823 32139 16782 42056 12383 68841 10091 27350 34164 20975 12762 5416 365 30052 75274 70111 66337 48457 52118 53...

output:

2
0
2
0
4
2
1
0

result:

ok 8 numbers

Test #20:

score: 0
Accepted
time: 345ms
memory: 65712kb

input:

99996 99990
99997
99996 52821 71994 5412 81583 73157 48354 18425 50528 27360 75535 7067 65310 76416 78124 1075 44589 90716 96328 75467 21323 71485 47779 68453 72864 24841 44657 21947 86837 22167 20326 43560 86657 44462 85892 60672 5855 15494 97522 45935 77692 42437 31984 72222 41898 5137 56079 68463...

output:

1
0
0
0
0
0
0
0
4
3

result:

ok 10 numbers