QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#302243#7951. Magic CardsYarema#AC ✓152ms17320kbC++201.1kb2024-01-10 17:59:272024-01-10 17:59:28

Judging History

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

  • [2024-01-10 17:59:28]
  • 评测
  • 测评结果:AC
  • 用时:152ms
  • 内存:17320kb
  • [2024-01-10 17:59:27]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;

const int N = 500'447;
__int128 d[N];

int main()
{
	ios::sync_with_stdio(0); 
	cin.tie(0);
	cout << fixed << setprecision(15);
	
	int n, k, m, f;
	cin >> n >> k >> m >> f;
	
	__int128 one = 1;
	vector<VI> v(k, VI(m));
	FOR (i, 0, k)
	{
		FOR (j, 0, m)
		{
			cin >> v[i][j];
			d[v[i][j]] |= one << i;
		}
	}
	set<__int128> bad;
	map<__int128, int> ans;
	FOR (i, 1, n + 1)
	{
		if (ans.count(d[i]))
			bad.insert(d[i]);
		else
			ans[d[i]] = i;
	}
	FOR (i, 0, f)
	{
		string s;
		cin >> s;
		__int128 res = 0;
		FOR (j, 0, k)
			if (s[j] == 'Y')
				res |= one << j;
		if (bad.count(res))
			cout << 0 << '\n';
		else
			cout << ans[res] << '\n';
	}
	
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3816kb

input:

12 4 6 3
1 9 7 11 3 5
2 10 3 6 7 11
4 5 6 7 6 12
8 11 10 9 12 9
YYNY
NNNY
YNNN

output:

11
8
1

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

13 4 6 4
1 9 7 11 3 5
2 10 3 6 7 11
4 5 6 7 6 12
8 11 10 9 12 9
YYNY
NNNY
YNNN
NNNN

output:

11
8
1
13

result:

ok 4 lines

Test #3:

score: 0
Accepted
time: 0ms
memory: 3488kb

input:

14 4 6 4
1 9 7 11 3 5
2 10 3 6 7 11
4 5 6 7 6 12
8 11 10 9 12 9
YYNY
NNNY
YNNN
NNNN

output:

11
8
1
0

result:

ok 4 lines

Test #4:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

1 1 1 1
1
Y

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3768kb

input:

1 100 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
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY...

output:

1

result:

ok single line: '1'

Test #6:

score: 0
Accepted
time: 15ms
memory: 5164kb

input:

1 100 5000 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 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...

output:

1

result:

ok single line: '1'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

2 1 1 2
1
Y
N

output:

1
2

result:

ok 2 lines

Test #8:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

2 2 1 2
1
2
YN
NY

output:

1
2

result:

ok 2 lines

Test #9:

score: 0
Accepted
time: 0ms
memory: 3544kb

input:

3 2 1 3
1
2
YN
NY
NN

output:

1
2
3

result:

ok 3 lines

Test #10:

score: 0
Accepted
time: 0ms
memory: 3544kb

input:

3 3 1 3
1
2
3
YNN
NYN
NNY

output:

1
2
3

result:

ok 3 lines

Test #11:

score: 0
Accepted
time: 0ms
memory: 3764kb

input:

4 3 1 4
1
2
3
YNN
NYN
NNY
NNN

output:

1
2
3
4

result:

ok 4 lines

Test #12:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

10 10 1 2
1
1
1
1
1
1
1
1
1
1
YYYYYYYYYY
NNNNNNNNNN

output:

1
0

result:

ok 2 lines

Test #13:

score: 0
Accepted
time: 0ms
memory: 3536kb

input:

100 100 1 100
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
9...

output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

result:

ok 100 lines

Test #14:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

101 100 1 101
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
9...

output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101

result:

ok 101 lines

Test #15:

score: 0
Accepted
time: 30ms
memory: 5192kb

input:

500000 100 5000 50000
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 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:

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
0
1
2
3
4
...

result:

ok 50000 lines

Test #16:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

2 2 2 2
1 2
1 1
YY
YN

output:

1
2

result:

ok 2 lines

Test #17:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

2 2 2 1
1 2
1 2
YY

output:

0

result:

ok single line: '0'

Test #18:

score: 0
Accepted
time: 0ms
memory: 3524kb

input:

3 2 2 3
1 2
1 1
YY
YN
NN

output:

1
2
3

result:

ok 3 lines

Test #19:

score: 0
Accepted
time: 0ms
memory: 3536kb

input:

3 2 2 2
1 2
1 2
YY
NN

output:

0
3

result:

ok 2 lines

Test #20:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

32 5 16 32
13 7 5 9 27 1 31 23 19 25 15 11 21 17 29 3
10 11 25 28 29 30 13 9 26 15 27 14 8 24 31 12
30 3 7 10 22 19 27 11 31 23 26 6 14 18 2 15
23 15 21 4 13 14 30 5 29 12 28 7 31 6 22 20
26 21 20 16 31 27 22 18 23 25 17 19 29 24 30 28
NYNNY
YYYNY
NNNNN
YYYYN
NYNYY
NNYYN
YYNNN
YNYNY
NYYNY
YNYYN
YNYN...

output:

24
27
32
15
28
6
9
19
26
7
3
22
13
16
5
23
25
30
31
17
8
14
29
21
2
4
1
12
18
11
20
10

result:

ok 32 lines

Test #21:

score: 0
Accepted
time: 1ms
memory: 3720kb

input:

1024 10 512 1024
630 661 910 732 639 991 775 689 716 520 656 802 526 897 860 899 564 733 678 782 787 542 717 923 814 635 519 840 699 958 714 835 1010 993 587 826 691 890 652 836 648 576 1019 554 974 917 668 553 690 521 919 969 856 953 791 669 907 810 981 977 842 950 955 672 539 867 916 762 925 816 5...

output:

1010
94
47
499
577
871
940
522
799
521
458
570
496
869
573
752
149
929
667
453
990
835
881
634
512
937
136
627
358
167
893
227
132
1018
926
85
834
853
928
546
414
841
114
784
913
874
640
836
1009
930
361
763
771
285
262
1017
808
781
353
446
866
843
623
430
904
615
911
1014
110
606
610
597
333
613
21...

result:

ok 1024 lines

Test #22:

score: 0
Accepted
time: 6ms
memory: 6544kb

input:

8192 13 4096 8192
1444 2857 4090 6599 3865 7966 5520 5524 6095 7046 8036 4425 2530 4038 5043 2978 4015 1875 2331 6142 2841 7488 2971 807 1361 5433 4528 1995 5957 1331 402 1445 5939 2981 7070 1534 4517 5455 5053 2461 5405 7142 3550 8132 4512 5000 7145 3346 2429 3843 2374 4094 439 4409 2856 3057 333 1...

output:

1632
3847
2565
1278
7339
2302
3005
3974
2723
5257
4045
4744
3137
4475
1569
1242
1147
3888
4772
41
5609
2399
6390
3342
165
3217
3744
2945
1289
4139
199
2656
5683
899
5725
315
2741
3130
4682
4515
2028
2894
1960
6250
1690
4819
4072
4259
7625
7129
1342
3235
1657
2032
5324
2128
8072
4302
6142
5300
2865
4...

result:

ok 8192 lines

Test #23:

score: 0
Accepted
time: 16ms
memory: 4508kb

input:

8192 13 4096 50000
7501 7368 5471 3648 1042 3331 5208 5889 3329 1418 3866 5571 6055 3505 3632 6079 8012 1817 3611 5152 5145 1092 1900 1938 1460 8035 3419 3210 7579 1429 7541 5723 1448 6019 5878 7597 1265 3087 3630 7561 1190 2011 7556 3256 7431 3496 3741 1301 5195 7979 3676 3178 3639 3936 1371 1332 3...

output:

6088
7795
7082
5577
3344
2584
5430
7759
6644
1384
4953
3968
3555
4739
6649
1435
3549
240
688
5925
2172
7272
3375
3774
7170
4055
840
369
6592
4341
5995
1443
629
5562
4928
4682
2242
2097
964
2626
2458
1032
7657
6924
4848
2685
3980
6374
4109
106
3823
1471
1031
4508
5559
7999
1044
1026
3464
4673
1691
72...

result:

ok 50000 lines

Test #24:

score: 0
Accepted
time: 24ms
memory: 4596kb

input:

500000 13 4096 50000
7501 7368 5471 3648 1042 3331 5208 5889 3329 1418 3866 5571 6055 3505 3632 6079 8012 1817 3611 5152 5145 1092 1900 1938 1460 8035 3419 3210 7579 1429 7541 5723 1448 6019 5878 7597 1265 3087 3630 7561 1190 2011 7556 3256 7431 3496 3741 1301 5195 7979 3676 3178 3639 3936 1371 1332...

output:

6088
7795
7082
5577
3344
2584
5430
7759
6644
1384
4953
3968
3555
4739
6649
1435
3549
240
688
5925
2172
7272
3375
3774
7170
4055
840
369
6592
4341
5995
1443
629
5562
4928
4682
2242
2097
964
2626
2458
1032
7657
6924
4848
2685
3980
6374
4109
106
3823
1471
1031
4508
5559
7999
1044
1026
3464
4673
1691
72...

result:

ok 50000 lines

Test #25:

score: 0
Accepted
time: 57ms
memory: 5824kb

input:

500000 91 4096 50000
7501 7368 5471 3648 1042 3331 5208 5889 3329 1418 3866 5571 6055 3505 3632 6079 8012 1817 3611 5152 5145 1092 1900 1938 1460 8035 3419 3210 7579 1429 7541 5723 1448 6019 5878 7597 1265 3087 3630 7561 1190 2011 7556 3256 7431 3496 3741 1301 5195 7979 3676 3178 3639 3936 1371 1332...

output:

6088
7795
7082
5577
3344
2584
5430
7759
6644
1384
4953
3968
3555
4739
6649
1435
3549
240
688
5925
2172
7272
3375
3774
7170
4055
840
369
6592
4341
5995
1443
629
5562
4928
4682
2242
2097
964
2626
2458
1032
7657
6924
4848
2685
3980
6374
4109
106
3823
1471
1031
4508
5559
7999
1044
1026
3464
4673
1691
72...

result:

ok 50000 lines

Test #26:

score: 0
Accepted
time: 25ms
memory: 3844kb

input:

1024 100 512 50000
756 887 942 486 943 614 314 556 118 426 424 369 805 227 305 510 419 440 932 754 230 247 96 626 50 930 172 309 242 944 427 759 308 102 511 166 233 254 619 693 160 363 504 445 509 755 928 938 814 567 383 822 173 382 302 821 552 929 251 744 763 46 490 127 888 364 870 931 359 244 628 ...

output:

33
326
26
620
142
294
784
84
499
634
816
330
728
954
214
770
645
32
870
102
564
468
23
691
666
469
268
57
274
882
1022
37
495
463
246
653
323
371
175
749
361
14
492
405
307
652
68
757
252
979
705
78
694
227
1024
787
286
865
935
421
375
127
577
930
225
635
866
650
282
380
580
650
29
155
945
111
810
9...

result:

ok 50000 lines

Test #27:

score: 0
Accepted
time: 32ms
memory: 4080kb

input:

500000 100 512 50000
756 887 942 486 943 614 314 556 118 426 424 369 805 227 305 510 419 440 932 754 230 247 96 626 50 930 172 309 242 944 427 759 308 102 511 166 233 254 619 693 160 363 504 445 509 755 928 938 814 567 383 822 173 382 302 821 552 929 251 744 763 46 490 127 888 364 870 931 359 244 62...

output:

33
326
26
620
142
294
784
84
499
634
816
330
728
954
214
770
645
32
870
102
564
468
23
691
666
469
268
57
274
882
1022
37
495
463
246
653
323
371
175
749
361
14
492
405
307
652
68
757
252
979
705
78
694
227
0
787
286
865
935
421
375
127
577
930
225
635
866
650
282
380
580
650
29
155
945
111
810
954
...

result:

ok 50000 lines

Test #28:

score: 0
Accepted
time: 14ms
memory: 3784kb

input:

32 100 16 50000
30 6 22 12 28 23 14 13 31 15 7 4 29 21 20 5
20 16 26 19 29 27 18 17 28 31 30 21 24 22 25 23
8 29 30 13 24 28 26 27 15 12 14 25 9 31 10 11
31 13 27 11 7 9 15 19 17 21 5 3 29 1 25 23
3 14 10 18 6 31 26 23 2 15 27 22 11 19 30 7
30 6 22 12 28 23 14 13 31 15 7 4 29 21 20 5
20 16 26 19 29 ...

output:

17
31
23
8
28
2
31
23
30
24
22
4
23
21
21
1
2
28
2
32
26
18
8
26
6
29
28
21
23
16
31
9
14
9
8
14
12
29
28
3
13
19
13
21
29
2
20
23
15
12
17
22
31
14
23
20
4
6
15
21
26
7
19
20
4
23
27
19
9
19
15
5
27
1
7
3
24
6
2
14
32
5
17
6
27
18
16
28
15
14
12
9
8
17
4
26
26
16
24
7
22
24
21
7
2
21
20
16
9
21
1
2...

result:

ok 50000 lines

Test #29:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

12 4 6 12
1 9 7 11 3 5
2 10 3 6 7 11
4 5 6 7 6 12
8 11 10 9 12 9
YNNN
NYNN
YYNN
NNYN
YNYN
NYYN
YYYN
NNNY
YNNY
NYNY
YYNY
NNYY

output:

1
2
3
4
5
6
7
8
9
10
11
12

result:

ok 12 lines

Test #30:

score: 0
Accepted
time: 0ms
memory: 3768kb

input:

13 4 6 13
1 9 7 11 3 5
2 10 3 6 7 11
4 5 6 7 6 12
8 11 10 9 12 9
YNNN
NYNN
YYNN
NNYN
YNYN
NYYN
YYYN
NNNY
YNNY
NYNY
YYNY
NNYY
NNNN

output:

1
2
3
4
5
6
7
8
9
10
11
12
13

result:

ok 13 lines

Test #31:

score: 0
Accepted
time: 0ms
memory: 3532kb

input:

14 4 6 14
1 9 7 11 3 5
2 10 3 6 7 11
4 5 6 7 6 12
8 11 10 9 12 9
YNNN
NYNN
YYNN
NNYN
YNYN
NYYN
YYYN
NNNY
YNNY
NYNY
YYNY
NNYY
NNNN
NNNN

output:

1
2
3
4
5
6
7
8
9
10
11
12
0
0

result:

ok 14 lines

Test #32:

score: 0
Accepted
time: 1ms
memory: 3548kb

input:

100 10 30 300
73 17 6 48 78 62 29 48 58 77 56 33 61 82 95 84 36 92 59 62 41 59 86 100 14 3 33 72 35 98
13 95 46 15 53 78 33 52 88 19 64 40 34 82 66 55 45 94 37 88 47 48 8 14 14 12 98 33 85 51
41 65 30 19 65 71 85 61 73 23 16 27 41 76 6 16 53 15 64 86 99 16 14 69 35 41 6 59 91 9
9 77 60 81 17 73 98 1...

output:

0
0
0
34
21
0
68
90
32
79
76
0
24
54
0
64
0
81
37
52
0
45
0
40
6
63
0
0
0
0
12
41
68
99
6
0
8
70
0
0
0
12
0
0
67
7
62
0
85
0
0
0
0
0
74
53
5
64
76
8
0
57
0
21
0
0
0
76
60
21
46
75
0
68
69
68
0
60
53
0
0
41
0
53
78
0
8
0
67
0
0
0
0
45
15
0
91
69
0
0
31
0
22
76
5
46
0
17
0
54
73
76
0
46
61
41
19
63
0
...

result:

ok 300 lines

Test #33:

score: 0
Accepted
time: 1ms
memory: 3580kb

input:

100 10 30 5000
1 13 99 49 71 69 90 2 16 68 19 14 54 51 47 92 66 66 61 17 75 29 47 53 36 42 65 47 82 96
85 28 88 64 97 72 26 15 78 22 91 55 82 89 38 2 65 20 15 68 48 52 29 96 74 28 85 11 28 56
72 79 12 69 60 10 88 35 42 44 68 78 57 35 15 11 21 72 70 100 54 79 24 93 2 85 83 32 98 42
52 25 46 16 19 65 ...

output:

31
85
0
38
0
0
46
0
0
0
0
0
0
31
69
10
71
0
70
0
31
47
0
0
0
70
0
98
47
0
87
53
92
88
0
92
14
92
68
41
0
11
0
67
0
54
0
67
0
88
27
69
11
0
0
0
0
31
0
31
0
0
86
0
60
60
67
0
11
0
79
0
0
99
99
29
0
0
0
94
100
0
55
88
0
66
23
72
72
33
81
0
85
23
16
0
0
69
52
54
0
77
0
94
66
8
0
72
0
25
65
0
38
10
73
0
...

result:

ok 5000 lines

Test #34:

score: 0
Accepted
time: 6ms
memory: 3780kb

input:

100 10 30 50000
39 85 51 80 72 47 80 35 76 38 56 99 25 34 91 55 70 52 68 29 84 30 83 80 73 57 36 4 22 70
71 20 76 81 27 90 97 30 99 54 96 2 85 100 77 4 20 27 86 45 49 63 44 79 90 96 52 4 31 86
55 48 58 44 42 68 19 49 72 99 93 35 49 68 63 72 60 50 67 54 84 88 17 6 81 33 10 77 50 74
38 87 36 85 69 42 ...

output:

0
0
0
0
2
57
20
51
2
74
85
0
0
56
3
2
61
0
66
0
0
57
60
84
0
77
0
0
86
68
97
32
10
51
44
0
0
69
2
0
70
9
0
0
0
90
0
0
0
83
0
19
42
70
57
90
74
0
5
0
85
96
9
0
0
51
32
0
20
86
57
88
0
24
0
0
0
0
0
59
0
99
46
60
0
0
61
20
13
0
94
85
24
0
78
87
99
78
17
19
24
0
13
68
0
53
0
32
78
61
0
0
96
24
0
0
69
86...

result:

ok 50000 lines

Test #35:

score: 0
Accepted
time: 0ms
memory: 4164kb

input:

10000 100 100 5000
1307 1514 5721 9195 8314 3332 1013 8542 5828 6776 9206 4969 289 1599 4106 8786 9658 6684 1686 7062 757 1922 8776 5837 3590 8966 7121 8790 1802 2057 2092 7072 1702 1469 7495 7129 2366 7409 80 5663 225 7456 9298 7015 2279 2487 1137 8879 715 3636 7562 6961 2026 7140 2504 6588 8168 48...

output:

0
0
7638
0
0
0
0
0
1004
0
0
4196
0
0
5530
0
0
2306
4328
0
5655
0
4730
0
5149
4946
0
0
0
0
0
0
0
0
4420
0
0
0
0
0
0
0
0
0
0
0
0
0
3653
0
8789
8795
0
0
0
0
0
0
672
0
0
0
0
2874
0
0
0
6193
0
0
0
6329
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4509
0
0
0
0
2693
4520
0
6666
0
0
9754
0
0
0
5929
0
9522
0
7767
0
0
0
0
5...

result:

ok 5000 lines

Test #36:

score: 0
Accepted
time: 9ms
memory: 4240kb

input:

10000 100 100 50000
329 4645 7736 3060 1374 6398 1674 4887 1084 1469 9062 4045 1627 62 2362 4859 6416 9201 9832 5072 4492 3783 8357 3530 4515 6145 4903 4270 308 6735 9308 4043 8104 2185 7887 6566 6590 2469 7031 355 6215 7533 9647 1408 3749 3155 767 148 4455 1150 7757 2578 1519 2032 2086 1483 4552 43...

output:

0
0
0
0
0
0
3852
0
0
0
0
4661
0
0
9480
0
0
0
0
0
0
5294
0
0
0
0
0
0
0
0
1972
2271
0
0
0
5637
0
0
0
0
0
0
0
0
9575
0
4468
0
0
0
0
0
0
0
6013
0
7888
0
662
8146
0
0
0
8072
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3933
0
0
0
0
2155
0
7441
0
0
0
0
6362
0
0
8179
0
0
0
4911
0
0
0
0
3541
0
0
0
0
0
0
7091
0
0
3060
7977
0...

result:

ok 50000 lines

Test #37:

score: 0
Accepted
time: 12ms
memory: 4940kb

input:

10000 100 1000 10000
4488 3960 8424 6836 1005 9848 9394 6664 6826 7635 6075 1637 1086 4487 8228 8994 6630 6522 165 8921 8100 2742 2198 7938 9825 6770 2278 4186 8180 4080 819 2249 5776 9838 2027 3440 3850 7215 7159 1969 7420 400 5563 8467 7268 5993 9359 8385 3541 5755 3148 690 6564 7682 7682 2451 439...

output:

2140
2740
5852
1186
8202
3859
5788
5407
5602
9698
6286
4643
3804
775
6764
38
8570
7774
6782
9464
9061
1819
4802
5451
6227
5730
3705
260
8313
8611
4429
6420
4715
6692
5051
2388
9968
6064
5316
8833
7257
2329
1931
2542
8559
3435
7964
8891
816
2503
765
209
2323
9046
3458
8965
3843
3099
9404
5674
3327
92...

result:

ok 10000 lines

Test #38:

score: 0
Accepted
time: 28ms
memory: 4904kb

input:

10000 100 1000 50000
6553 7931 9627 3880 2878 8648 7640 4530 8050 6439 7084 2028 8640 3605 1558 7630 7325 8266 7649 9903 4268 2511 7044 4844 3842 608 7355 2161 4115 2482 2062 2191 5093 8458 4117 8814 2640 2086 6031 9947 3778 8649 1390 3248 6399 4177 9027 6787 2918 7911 5486 9881 9959 9656 9818 597 8...

output:

5589
2596
1420
8933
2658
844
3109
9623
7237
9276
8518
1209
90
3349
2400
8201
2705
2346
6716
4683
5377
5424
1915
8616
8810
2852
9788
6930
948
5375
590
3964
1307
702
5274
7664
3009
4118
5469
4344
9402
1949
9326
2213
3630
5841
5217
2792
2932
6802
3612
2542
8744
6634
5139
9118
8071
2969
8297
6649
9280
6...

result:

ok 50000 lines

Test #39:

score: 0
Accepted
time: 26ms
memory: 6444kb

input:

10000 100 5000 10000
9170 4331 9420 6540 6474 4523 1885 1285 6836 2533 9356 6432 2495 2890 5105 1090 369 5130 8717 8923 9120 5497 2706 2365 9389 9929 27 1773 3294 1223 978 6724 7244 7279 4792 1549 7133 7604 1610 8992 3278 8261 7503 7550 7762 5827 6412 4254 7306 6886 3934 4147 3245 9145 6470 7136 320...

output:

3911
7243
1380
5369
9199
105
946
1397
1547
4990
103
4142
4172
4616
9598
2859
6535
2728
9814
2367
2444
5554
9857
2354
5253
9494
8636
2216
7086
9376
6378
4155
192
5084
2859
6148
3134
2835
412
9510
2176
3232
1107
5551
3250
383
621
511
6354
9818
6778
284
1283
2763
7410
7690
9917
2490
4136
1305
6179
1816...

result:

ok 10000 lines

Test #40:

score: 0
Accepted
time: 57ms
memory: 6444kb

input:

10000 100 5000 50000
3360 8574 2759 484 8855 6688 7331 8011 7857 6824 8759 7032 4804 6543 9659 9667 9239 4622 577 4943 7696 9197 3938 3020 9331 3153 9572 4994 9597 6180 981 8544 1289 1136 374 2698 9870 9132 5978 4346 1813 692 2705 4211 1026 3359 6297 1719 9866 9527 325 1451 1357 5315 3729 1272 4830 ...

output:

4061
7800
9560
1761
3474
3851
5534
1259
7942
3656
7967
928
7264
1232
8217
3147
4974
3820
2725
1951
8550
8497
4091
4254
9508
2926
2693
8423
2489
6263
2821
4151
2722
8868
1006
9462
8569
3711
3490
6201
8098
9500
2983
3678
614
4863
7458
7576
3052
3693
1840
5446
7639
1836
1036
5822
6510
6230
7894
1958
70...

result:

ok 50000 lines

Test #41:

score: 0
Accepted
time: 31ms
memory: 6620kb

input:

50000 100 1000 50000
10625 14567 41832 24873 1268 22123 2596 20158 43232 35360 48239 45609 5346 27678 14284 35039 5653 44764 27535 18457 35630 34161 2105 2091 43514 15886 12097 49035 26022 44093 17795 24548 24384 45238 16502 42151 24621 46628 15488 47419 24072 13536 34021 3705 28559 33303 44255 3041...

output:

6838
0
0
0
16215
22076
0
0
0
0
0
43478
0
0
0
0
0
40817
22854
33533
0
33576
6845
0
0
0
14549
0
0
8903
47805
0
11398
0
0
0
0
0
0
0
0
0
0
0
0
0
15464
0
34324
49725
24766
21184
38346
20311
0
30225
11143
0
0
0
48843
10129
39665
0
0
0
0
19277
0
7881
0
0
0
0
36935
0
5854
0
42897
0
44086
0
0
0
0
0
22217
312...

result:

ok 50000 lines

Test #42:

score: 0
Accepted
time: 67ms
memory: 12188kb

input:

50000 100 5000 50000
35819 12471 35289 25196 28687 26096 48746 29280 26305 6839 39883 15225 35310 15709 45604 38204 33259 39466 28649 30457 33983 42805 36007 47385 24382 2176 8355 13084 7925 25720 43865 26694 15695 21056 10713 39112 16538 31709 28801 33226 17024 49484 33349 3420 17498 42556 9714 361...

output:

1262
15144
31786
25092
20872
28785
33945
20776
5077
28153
46630
16503
19099
31494
20054
29137
27709
48015
33589
47916
37074
683
374
2666
42066
16711
33797
8515
27460
15168
5465
7384
1600
3872
7882
40987
17109
42067
23071
11076
10861
46230
10237
43780
46251
24518
47448
26760
5148
38303
31562
2931
313...

result:

ok 50000 lines

Test #43:

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

input:

100000 100 5000 50000
60903 60777 50862 75562 55817 6731 45681 62383 52642 10159 16932 9683 19578 39815 38932 77104 67979 68211 16001 27780 70451 66849 8094 37955 45169 37768 63393 93533 50099 51 21352 32073 49154 94614 74357 23005 38454 14561 39920 58420 69420 75845 71416 26420 86356 1847 26938 310...

output:

27106
10527
57356
85663
2804
61023
41931
62558
78671
70009
86389
22017
12799
30114
63949
98
0
76787
16758
0
0
93066
0
98563
91061
94270
15753
39762
27943
35504
1641
77799
87823
0
95428
17645
94710
33006
36404
60842
89813
40850
0
69320
46241
267
68625
26171
82122
65698
14192
17514
25393
0
66174
0
562...

result:

ok 50000 lines

Test #44:

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

input:

100000 100 5000 50000
34256 96407 74082 2341 81621 41537 23483 67044 44578 50516 29887 44818 48556 47799 80405 16376 1439 57505 39538 86079 24708 83597 97896 57352 76901 40407 59939 41624 83581 18127 26504 98180 18605 13678 16598 25296 7386 34501 14760 72478 44811 58527 93153 62528 97030 70589 64943...

output:

97793
75096
95588
7300
83100
0
66064
0
94894
73355
75746
21696
23752
36869
84438
30001
0
18299
16469
76198
70179
88350
56258
94835
95822
95812
0
55246
52234
27749
74494
14214
55396
45457
14997
85267
42360
94694
39165
85042
0
71077
59280
8907
0
92185
36566
59540
13034
88231
98961
93704
0
4600
0
99226...

result:

ok 50000 lines

Test #45:

score: 0
Accepted
time: 141ms
memory: 17024kb

input:

500000 100 5000 50000
263435 304391 309018 265448 301077 72147 8025 52670 123309 418257 369939 362079 446868 302209 66323 27164 373251 302023 366840 370515 76677 239597 289980 483961 54443 430689 382910 264394 398450 371779 164323 224705 224706 362637 97057 63652 314180 235480 396975 422358 327738 3...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
8600
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
222061
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
451638
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
244148
0
0
0
0
0
0
0
0
0
0
0
367433
0
0
0
0
0
0
0
0
4...

result:

ok 50000 lines

Test #46:

score: 0
Accepted
time: 152ms
memory: 17320kb

input:

500000 100 5000 50000
110532 336353 375520 4348 463747 494205 226949 119004 452361 61579 62267 135717 78491 224239 339662 368667 92893 107811 407357 10137 120870 383602 140370 250662 168932 320609 472434 114556 266048 281644 407485 438407 244547 212274 327356 393176 172255 74604 253840 59607 354319 ...

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
176137
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
471995
0
0
0
0
0
0
0
0
0
0
0
0
0
0
418557
0
0
0
0
0
0
0
0
0
0
0
191861
0
0
0
0
0
0
0
0
0
243765
0
0
0
0
0
0
84987
0
0...

result:

ok 50000 lines