QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#133398#3269. 末日魔法少女计划zhouhuanyi24.005537 3ms3952kbC++231.1kb2023-08-02 08:04:462023-08-02 08:04:48

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-02 08:04:48]
  • 评测
  • 测评结果:24.005537
  • 用时:3ms
  • 内存:3952kb
  • [2023-08-02 08:04:46]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<vector>
#define N 100000
using namespace std;
int read()
{
	char c=0;
	int sum=0;
	while (c<'0'||c>'9') c=getchar();
	while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
	return sum;
}
struct reads
{
	int x,y;
};
reads tong[N+1];
int n,k,length;
void adder(int x,int y)
{
	tong[++length]=(reads){x,y};
	return;
}
void solve(int l,int r)
{
	if (r-l<=k) return;
	int d=(r-l+1)/k,ps=l;
	vector<int>s(n+1);
	vector<int>used(n+1);
	vector<int>p(k);
	for (int i=1;i<=k-1;++i) ps+=d,p[i]=ps,s[ps]=used[ps]=1;
	for (int i=l;i<=r;++i) s[i]+=s[i-1];
	for (int i=1;i<=k-2;++i)
		if (p[i+1]-p[i]>1)
			adder(p[i],p[i+1]);
	for (int i=l;i<=r;++i)
		if (!used[i])
		{
			if (s[i]&&i-p[s[i]]>1) adder(p[s[i]],i);
			if (s[i]!=k-1&&p[s[i]+1]-i>1) adder(i,p[s[i]+1]);
		}
	if (l<=p[1]-1) solve(l,p[1]-1);
	for (int i=1;i<=k-2;++i)
		if (p[i]+1<=p[i+1]-1)
			solve(p[i]+1,p[i+1]-1);
	if (p[k-1]+1<=r) solve(p[k-1]+1,r);
	return;
}
int main()
{
	n=read(),k=read(),solve(0,n),printf("%d\n",length);
	for (int i=1;i<=length;++i) printf("%d %d\n",tong[i].x,tong[i].y);
	return 0;
}

详细

Subtask #1:

score: 22
Accepted

Test #1:

score: 22
Accepted
time: 3ms
memory: 3892kb

input:

2000 2

output:

15974
0 1000
1 1000
2 1000
3 1000
4 1000
5 1000
6 1000
7 1000
8 1000
9 1000
10 1000
11 1000
12 1000
13 1000
14 1000
15 1000
16 1000
17 1000
18 1000
19 1000
20 1000
21 1000
22 1000
23 1000
24 1000
25 1000
26 1000
27 1000
28 1000
29 1000
30 1000
31 1000
32 1000
33 1000
34 1000
35 1000
36 1000
37 1000
...

result:

ok 

Test #2:

score: 22
Accepted
time: 3ms
memory: 3888kb

input:

1999 2

output:

15965
0 1000
1 1000
2 1000
3 1000
4 1000
5 1000
6 1000
7 1000
8 1000
9 1000
10 1000
11 1000
12 1000
13 1000
14 1000
15 1000
16 1000
17 1000
18 1000
19 1000
20 1000
21 1000
22 1000
23 1000
24 1000
25 1000
26 1000
27 1000
28 1000
29 1000
30 1000
31 1000
32 1000
33 1000
34 1000
35 1000
36 1000
37 1000
...

result:

ok 

Test #3:

score: 22
Accepted
time: 0ms
memory: 3892kb

input:

1992 2

output:

15902
0 996
1 996
2 996
3 996
4 996
5 996
6 996
7 996
8 996
9 996
10 996
11 996
12 996
13 996
14 996
15 996
16 996
17 996
18 996
19 996
20 996
21 996
22 996
23 996
24 996
25 996
26 996
27 996
28 996
29 996
30 996
31 996
32 996
33 996
34 996
35 996
36 996
37 996
38 996
39 996
40 996
41 996
42 996
43 ...

result:

ok 

Test #4:

score: 22
Accepted
time: 3ms
memory: 3952kb

input:

1973 2

output:

15731
0 987
1 987
2 987
3 987
4 987
5 987
6 987
7 987
8 987
9 987
10 987
11 987
12 987
13 987
14 987
15 987
16 987
17 987
18 987
19 987
20 987
21 987
22 987
23 987
24 987
25 987
26 987
27 987
28 987
29 987
30 987
31 987
32 987
33 987
34 987
35 987
36 987
37 987
38 987
39 987
40 987
41 987
42 987
43 ...

result:

ok 

Test #5:

score: 22
Accepted
time: 3ms
memory: 3880kb

input:

1936 2

output:

15398
0 968
1 968
2 968
3 968
4 968
5 968
6 968
7 968
8 968
9 968
10 968
11 968
12 968
13 968
14 968
15 968
16 968
17 968
18 968
19 968
20 968
21 968
22 968
23 968
24 968
25 968
26 968
27 968
28 968
29 968
30 968
31 968
32 968
33 968
34 968
35 968
36 968
37 968
38 968
39 968
40 968
41 968
42 968
43 ...

result:

ok 

Subtask #2:

score: 2.00554
Acceptable Answer

Test #6:

score: 2.09713
Acceptable Answer
time: 0ms
memory: 3876kb

input:

1936 3

output:

12703
645 1290
0 645
1 645
2 645
3 645
4 645
5 645
6 645
7 645
8 645
9 645
10 645
11 645
12 645
13 645
14 645
15 645
16 645
17 645
18 645
19 645
20 645
21 645
22 645
23 645
24 645
25 645
26 645
27 645
28 645
29 645
30 645
31 645
32 645
33 645
34 645
35 645
36 645
37 645
38 645
39 645
40 645
41 645
4...

result:

points 0.14979526720

Test #7:

score: 2.00554
Acceptable Answer
time: 3ms
memory: 3932kb

input:

2000 3

output:

13208
667 1334
0 667
1 667
2 667
3 667
4 667
5 667
6 667
7 667
8 667
9 667
10 667
11 667
12 667
13 667
14 667
15 667
16 667
17 667
18 667
19 667
20 667
21 667
22 667
23 667
24 667
25 667
26 667
27 667
28 667
29 667
30 667
31 667
32 667
33 667
34 667
35 667
36 667
37 667
38 667
39 667
40 667
41 667
4...

result:

points 0.14325265290

Test #8:

score: 2.00704
Acceptable Answer
time: 0ms
memory: 3888kb

input:

1999 3

output:

13200
666 1332
0 666
1 666
2 666
3 666
4 666
5 666
6 666
7 666
8 666
9 666
10 666
11 666
12 666
13 666
14 666
15 666
16 666
17 666
18 666
19 666
20 666
21 666
22 666
23 666
24 666
25 666
26 666
27 666
28 666
29 666
30 666
31 666
32 666
33 666
34 666
35 666
36 666
37 666
38 666
39 666
40 666
41 666
4...

result:

points 0.14335967240

Test #9:

score: 2.01541
Acceptable Answer
time: 1ms
memory: 3816kb

input:

1992 3

output:

13146
664 1328
0 664
1 664
2 664
3 664
4 664
5 664
6 664
7 664
8 664
9 664
10 664
11 664
12 664
13 664
14 664
15 664
16 664
17 664
18 664
19 664
20 664
21 664
22 664
23 664
24 664
25 664
26 664
27 664
28 664
29 664
30 664
31 664
32 664
33 664
34 664
35 664
36 664
37 664
38 664
39 664
40 664
41 664
4...

result:

points 0.14395820220

Test #10:

score: 2.03678
Acceptable Answer
time: 0ms
memory: 3816kb

input:

1973 3

output:

13001
658 1316
0 658
1 658
2 658
3 658
4 658
5 658
6 658
7 658
8 658
9 658
10 658
11 658
12 658
13 658
14 658
15 658
16 658
17 658
18 658
19 658
20 658
21 658
22 658
23 658
24 658
25 658
26 658
27 658
28 658
29 658
30 658
31 658
32 658
33 658
34 658
35 658
36 658
37 658
38 658
39 658
40 658
41 658
4...

result:

points 0.14548397830

Subtask #3:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 2ms
memory: 3796kb

input:

2000 4

output:

11512
500 1000
1000 1500
0 500
1 500
2 500
3 500
4 500
5 500
6 500
7 500
8 500
9 500
10 500
11 500
12 500
13 500
14 500
15 500
16 500
17 500
18 500
19 500
20 500
21 500
22 500
23 500
24 500
25 500
26 500
27 500
28 500
29 500
30 500
31 500
32 500
33 500
34 500
35 500
36 500
37 500
38 500
39 500
40 50...

result:

wrong answer 

Subtask #4:

score: 0
Wrong Answer

Test #16:

score: 0
Wrong Answer
time: 2ms
memory: 3764kb

input:

2000 5

output:

10456
400 800
800 1200
1200 1600
0 400
1 400
2 400
3 400
4 400
5 400
6 400
7 400
8 400
9 400
10 400
11 400
12 400
13 400
14 400
15 400
16 400
17 400
18 400
19 400
20 400
21 400
22 400
23 400
24 400
25 400
26 400
27 400
28 400
29 400
30 400
31 400
32 400
33 400
34 400
35 400
36 400
37 400
38 400
39 4...

result:

wrong answer 

Subtask #5:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 2ms
memory: 3772kb

input:

2000 6

output:

9540
333 666
666 999
999 1332
1332 1665
0 333
1 333
2 333
3 333
4 333
5 333
6 333
7 333
8 333
9 333
10 333
11 333
12 333
13 333
14 333
15 333
16 333
17 333
18 333
19 333
20 333
21 333
22 333
23 333
24 333
25 333
26 333
27 333
28 333
29 333
30 333
31 333
32 333
33 333
34 333
35 333
36 333
37 333
38 3...

result:

wrong answer 

Subtask #6:

score: 0
Wrong Answer

Test #26:

score: 0
Wrong Answer
time: 2ms
memory: 3768kb

input:

1999 7

output:

9023
285 570
570 855
855 1140
1140 1425
1425 1710
0 285
1 285
2 285
3 285
4 285
5 285
6 285
7 285
8 285
9 285
10 285
11 285
12 285
13 285
14 285
15 285
16 285
17 285
18 285
19 285
20 285
21 285
22 285
23 285
24 285
25 285
26 285
27 285
28 285
29 285
30 285
31 285
32 285
33 285
34 285
35 285
36 285
3...

result:

wrong answer 

Subtask #7:

score: 0
Wrong Answer

Test #31:

score: 0
Wrong Answer
time: 2ms
memory: 3744kb

input:

1995 8

output:

8525
249 498
498 747
747 996
996 1245
1245 1494
1494 1743
0 249
1 249
2 249
3 249
4 249
5 249
6 249
7 249
8 249
9 249
10 249
11 249
12 249
13 249
14 249
15 249
16 249
17 249
18 249
19 249
20 249
21 249
22 249
23 249
24 249
25 249
26 249
27 249
28 249
29 249
30 249
31 249
32 249
33 249
34 249
35 249
...

result:

wrong answer 

Subtask #8:

score: 0
Wrong Answer

Test #36:

score: 0
Wrong Answer
time: 2ms
memory: 3744kb

input:

1997 9

output:

7985
222 444
444 666
666 888
888 1110
1110 1332
1332 1554
1554 1776
0 222
1 222
2 222
3 222
4 222
5 222
6 222
7 222
8 222
9 222
10 222
11 222
12 222
13 222
14 222
15 222
16 222
17 222
18 222
19 222
20 222
21 222
22 222
23 222
24 222
25 222
26 222
27 222
28 222
29 222
30 222
31 222
32 222
33 222
34 2...

result:

wrong answer 

Subtask #9:

score: 0
Wrong Answer

Test #41:

score: 0
Wrong Answer
time: 0ms
memory: 3744kb

input:

1995 10

output:

7603
199 398
398 597
597 796
796 995
995 1194
1194 1393
1393 1592
1592 1791
0 199
1 199
2 199
3 199
4 199
5 199
6 199
7 199
8 199
9 199
10 199
11 199
12 199
13 199
14 199
15 199
16 199
17 199
18 199
19 199
20 199
21 199
22 199
23 199
24 199
25 199
26 199
27 199
28 199
29 199
30 199
31 199
32 199
33 ...

result:

wrong answer 

Subtask #10:

score: 0
Wrong Answer

Test #46:

score: 0
Wrong Answer
time: 2ms
memory: 3740kb

input:

1993 11

output:

7253
181 362
362 543
543 724
724 905
905 1086
1086 1267
1267 1448
1448 1629
1629 1810
0 181
1 181
2 181
3 181
4 181
5 181
6 181
7 181
8 181
9 181
10 181
11 181
12 181
13 181
14 181
15 181
16 181
17 181
18 181
19 181
20 181
21 181
22 181
23 181
24 181
25 181
26 181
27 181
28 181
29 181
30 181
31 181
...

result:

wrong answer 

Subtask #11:

score: 0
Wrong Answer

Test #51:

score: 0
Wrong Answer
time: 2ms
memory: 3792kb

input:

1999 12

output:

6885
166 332
332 498
498 664
664 830
830 996
996 1162
1162 1328
1328 1494
1494 1660
1660 1826
0 166
1 166
2 166
3 166
4 166
5 166
6 166
7 166
8 166
9 166
10 166
11 166
12 166
13 166
14 166
15 166
16 166
17 166
18 166
19 166
20 166
21 166
22 166
23 166
24 166
25 166
26 166
27 166
28 166
29 166
30 166...

result:

wrong answer 

Subtask #12:

score: 0
Wrong Answer

Test #56:

score: 0
Wrong Answer
time: 0ms
memory: 3792kb

input:

1981 13

output:

6753
152 304
304 456
456 608
608 760
760 912
912 1064
1064 1216
1216 1368
1368 1520
1520 1672
1672 1824
0 152
1 152
2 152
3 152
4 152
5 152
6 152
7 152
8 152
9 152
10 152
11 152
12 152
13 152
14 152
15 152
16 152
17 152
18 152
19 152
20 152
21 152
22 152
23 152
24 152
25 152
26 152
27 152
28 152
29 ...

result:

wrong answer 

Subtask #13:

score: 0
Wrong Answer

Test #61:

score: 0
Wrong Answer
time: 2ms
memory: 3836kb

input:

1979 14

output:

6734
141 282
282 423
423 564
564 705
705 846
846 987
987 1128
1128 1269
1269 1410
1410 1551
1551 1692
1692 1833
0 141
1 141
2 141
3 141
4 141
5 141
6 141
7 141
8 141
9 141
10 141
11 141
12 141
13 141
14 141
15 141
16 141
17 141
18 141
19 141
20 141
21 141
22 141
23 141
24 141
25 141
26 141
27 141
28...

result:

wrong answer 

Subtask #14:

score: 0
Wrong Answer

Test #66:

score: 0
Wrong Answer
time: 2ms
memory: 3740kb

input:

2000 15

output:

6661
133 266
266 399
399 532
532 665
665 798
798 931
931 1064
1064 1197
1197 1330
1330 1463
1463 1596
1596 1729
1729 1862
0 133
1 133
2 133
3 133
4 133
5 133
6 133
7 133
8 133
9 133
10 133
11 133
12 133
13 133
14 133
15 133
16 133
17 133
18 133
19 133
20 133
21 133
22 133
23 133
24 133
25 133
26 133...

result:

wrong answer