QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#131901#2784. Aliensvalerikk#12 70ms6060kbC++171.5kb2023-07-28 21:27:022024-07-04 01:01:22

Judging History

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

  • [2024-07-04 01:01:22]
  • 评测
  • 测评结果:12
  • 用时:70ms
  • 内存:6060kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-28 21:27:02]
  • 提交

answer

#include "aliens.h"
#include <bits/stdc++.h>

using namespace std;

namespace {

typedef long long ll;

const int N = 505;
const ll INF = 0x3f3f3f3f3f3f3f3f;

int n, k;
int l[N], r[N];
ll dp[N][N];
ll pref[N];

}

ll take_photos(int grdn, int grdm, int grdk, vector<int> grdr, vector<int> grdc) {
	k = grdk;
	vector<pair<int, int>> segs;
	for (int i = 0; i < grdn; ++i) {
		int r = grdr[i];
		int c = grdc[i];
		if (r <= c) {
			segs.push_back({r, c + 1});
		} else {
			segs.push_back({c, r + 1});
		}
	}
	sort(segs.begin(), segs.end());
	n = 0;
	for (auto sg : segs) {
		int l1 = sg.first;
		int r1 = sg.second;
		if (n > 0 && l1 == l[n - 1] && r1 > r[n - 1]) {
			--n;
		}
		if (n == 0 || r1 > r[n - 1]) {
			while (n > 1 && r[n - 2] >= l1) {
				--n;
			}
			l[n] = l1;
			r[n] = r1;
			++n;
		}
	}
	pref[0] = 0;
	for (int i = 0; i < n; ++i) {
		pref[i + 1] = pref[i] + (r[i] - l[i]) * 1ll * (r[i] - l[i]);
	}
	memset(dp, 0x3f, sizeof dp);
	for (int i = 0; i < n; ++i) {
		dp[1][i + 1] = (r[i] - l[0]) * 1ll * (r[i] - l[0]) - pref[i + 1];
	}
	for (int t = 1; t < k; ++t) {
		for (int i = 1; i <= n; ++i) {
			dp[t + 1][i] = min(dp[t + 1][i], dp[t][i]);
		}
		for (int i = 1; i <= n; ++i) {
			for (int j = i + 1; j <= n; ++j) {
				dp[t + 1][j] = min(dp[t + 1][j], dp[t][i] + (r[j - 1] - l[i]) * 1ll * (r[j - 1] - l[i]) - pref[j] + pref[i]);
			}
		}
	}
	ll ans = dp[k][n];
	ans += pref[n];
	for (int i = 0; i < n - 1; ++i) {
		if (r[i] >= l[i + 1]) {
			ans -= (r[i] - l[i + 1]) * 1ll * (r[i] - l[i + 1]);
		}
	}
	return ans;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 4
Accepted
time: 1ms
memory: 5796kb

input:

2 6 2
1 4
4 1

output:

098d134608c94f7413faac591054ee35
16

result:

ok Correct answer: answer = 16

Test #2:

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

input:

1 2 1
0 1

output:

098d134608c94f7413faac591054ee35
4

result:

ok Correct answer: answer = 4

Test #3:

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

input:

2 2 2
0 0
1 0

output:

098d134608c94f7413faac591054ee35
4

result:

ok Correct answer: answer = 4

Test #4:

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

input:

2 3 2
0 1
1 1

output:

098d134608c94f7413faac591054ee35
4

result:

ok Correct answer: answer = 4

Test #5:

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

input:

4 4 4
1 3
0 1
2 1
2 2

output:

098d134608c94f7413faac591054ee35
12

result:

ok Correct answer: answer = 12

Test #6:

score: -4
Wrong Answer
time: 0ms
memory: 6060kb

input:

5 8 5
0 5
2 6
7 4
4 5
2 6

output:

098d134608c94f7413faac591054ee35
48

result:

wrong answer Wrong answer: output = 48, expected = 52

Subtask #2:

score: 12
Accepted

Test #23:

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

input:

2 2 1
0 0
1 1

output:

098d134608c94f7413faac591054ee35
4

result:

ok Correct answer: answer = 4

Test #24:

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

input:

4 3 2
0 0
0 0
0 0
0 0

output:

098d134608c94f7413faac591054ee35
1

result:

ok Correct answer: answer = 1

Test #25:

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

input:

5 5 2
2 2
3 3
4 4
3 3
3 3

output:

098d134608c94f7413faac591054ee35
5

result:

ok Correct answer: answer = 5

Test #26:

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

input:

10 20 3
3 3
15 15
10 10
18 18
4 4
7 7
15 15
2 2
10 10
7 7

output:

098d134608c94f7413faac591054ee35
41

result:

ok Correct answer: answer = 41

Test #27:

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

input:

20 1000 5
737 737
714 714
662 662
163 163
683 683
615 615
23 23
246 246
724 724
90 90
802 802
557 557
146 146
429 429
816 816
164 164
638 638
568 568
957 957
904 904

output:

098d134608c94f7413faac591054ee35
71923

result:

ok Correct answer: answer = 71923

Test #28:

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

input:

200 1000 10
69 69
277 277
350 350
753 753
741 741
849 849
993 993
95 95
928 928
789 789
333 333
795 795
493 493
253 253
661 661
780 780
17 17
394 394
487 487
719 719
426 426
297 297
885 885
323 323
981 981
916 916
0 0
997 997
757 757
374 374
467 467
787 787
297 297
216 216
599 599
62 62
936 936
777 ...

output:

098d134608c94f7413faac591054ee35
77137

result:

ok Correct answer: answer = 77137

Test #29:

score: 0
Accepted
time: 23ms
memory: 6040kb

input:

500 1000 250
599 599
14 14
176 176
963 963
93 93
257 257
403 403
741 741
854 854
862 862
778 778
489 489
711 711
623 623
163 163
750 750
649 649
441 441
245 245
311 311
429 429
756 756
572 572
766 766
837 837
137 137
719 719
244 244
519 519
287 287
251 251
818 818
789 789
305 305
400 400
262 262
359...

output:

098d134608c94f7413faac591054ee35
764

result:

ok Correct answer: answer = 764

Test #30:

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

input:

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

output:

098d134608c94f7413faac591054ee35
250000

result:

ok Correct answer: answer = 250000

Test #31:

score: 0
Accepted
time: 70ms
memory: 5732kb

input:

500 500 500
236 236
200 200
154 154
128 128
344 344
453 453
112 112
10 10
491 491
356 356
299 299
294 294
197 197
441 441
13 13
78 78
287 287
430 430
342 342
63 63
284 284
100 100
315 315
14 14
33 33
292 292
2 2
392 392
383 383
46 46
295 295
401 401
487 487
327 327
127 127
408 408
109 109
71 71
248 ...

output:

098d134608c94f7413faac591054ee35
500

result:

ok Correct answer: answer = 500

Test #32:

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

input:

4 9 2
0 0
3 3
5 5
8 8

output:

098d134608c94f7413faac591054ee35
32

result:

ok Correct answer: answer = 32

Test #33:

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

input:

500 510 2
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
13 13
14 14
15 15
16 16
17 17
18 18
19 19
20 20
21 21
22 22
23 23
24 24
25 25
26 26
27 27
28 28
29 29
30 30
31 31
32 32
33 33
34 34
35 35
36 36
37 37
38 38
39 39
40 40
41 41
42 42
43 43
44 44
45 45
46 46
47 47
48 48
49 49
50 50
51 5...

output:

098d134608c94f7413faac591054ee35
130050

result:

ok Correct answer: answer = 130050

Test #34:

score: 0
Accepted
time: 8ms
memory: 5780kb

input:

500 510 49
236 236
200 200
154 154
128 128
344 344
453 453
112 112
10 10
501 501
356 356
299 299
294 294
197 197
441 441
13 13
78 78
287 287
430 430
342 342
63 63
284 284
100 100
315 315
14 14
33 33
292 292
2 2
392 392
383 383
46 46
295 295
401 401
487 487
327 327
127 127
408 408
109 109
71 71
248 2...

output:

098d134608c94f7413faac591054ee35
5110

result:

ok Correct answer: answer = 5110

Test #35:

score: 0
Accepted
time: 2ms
memory: 5772kb

input:

256 256 25
236 236
200 200
154 154
128 128
146 146
177 177
112 112
10 10
185 185
147 147
134 134
138 138
197 197
108 108
13 13
78 78
111 111
99 99
119 119
63 63
59 59
100 100
40 40
14 14
33 33
131 131
2 2
60 60
167 167
46 46
249 249
64 64
98 98
42 42
127 127
195 195
109 109
71 71
248 248
114 114
148...

output:

098d134608c94f7413faac591054ee35
2626

result:

ok Correct answer: answer = 2626

Test #36:

score: 0
Accepted
time: 2ms
memory: 6060kb

input:

256 256 83
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
13 13
14 14
15 15
16 16
17 17
18 18
19 19
20 20
21 21
22 22
23 23
24 24
25 25
26 26
27 27
28 28
29 29
30 30
31 31
32 32
33 33
34 34
35 35
36 36
37 37
38 38
39 39
40 40
41 41
42 42
43 43
44 44
45 45
46 46
47 47
48 48
49 49
50 50
51 ...

output:

098d134608c94f7413faac591054ee35
796

result:

ok Correct answer: answer = 796

Test #37:

score: 0
Accepted
time: 5ms
memory: 5784kb

input:

500 500 33
236 236
200 200
154 154
128 128
344 344
453 453
112 112
10 10
491 491
356 356
299 299
294 294
197 197
441 441
13 13
78 78
287 287
430 430
342 342
63 63
284 284
100 100
315 315
14 14
33 33
292 292
2 2
392 392
383 383
46 46
295 295
401 401
487 487
327 327
127 127
408 408
109 109
71 71
248 2...

output:

098d134608c94f7413faac591054ee35
7580

result:

ok Correct answer: answer = 7580

Test #38:

score: 0
Accepted
time: 19ms
memory: 5812kb

input:

500 500 133
236 236
200 200
154 154
128 128
344 344
453 453
112 112
10 10
491 491
356 356
299 299
294 294
197 197
441 441
13 13
78 78
287 287
430 430
342 342
63 63
284 284
100 100
315 315
14 14
33 33
292 292
2 2
392 392
383 383
46 46
295 295
401 401
487 487
327 327
127 127
408 408
109 109
71 71
248 ...

output:

098d134608c94f7413faac591054ee35
1904

result:

ok Correct answer: answer = 1904

Test #39:

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

input:

500 1000 1
390 390
487 487
26 26
108 108
607 607
524 524
626 626
382 382
979 979
365 365
326 326
246 246
433 433
44 44
273 273
608 608
128 128
710 710
891 891
450 450
632 632
643 643
377 377
686 686
341 341
126 126
346 346
413 413
128 128
776 776
389 389
989 989
537 537
37 37
742 742
871 871
647 647...

output:

098d134608c94f7413faac591054ee35
996004

result:

ok Correct answer: answer = 996004

Test #40:

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

input:

500 1000 20
96 96
499 499
640 640
749 749
773 773
160 160
750 750
543 543
150 150
810 810
193 193
227 227
433 433
988 988
632 632
121 121
568 568
445 445
392 392
992 992
863 863
444 444
497 497
618 618
187 187
925 925
767 767
977 977
697 697
172 172
194 194
887 887
217 217
350 350
98 98
420 420
189 ...

output:

098d134608c94f7413faac591054ee35
38817

result:

ok Correct answer: answer = 38817

Test #41:

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

input:

500 1000 100
485 485
28 28
73 73
858 858
838 838
357 357
679 679
550 550
543 543
835 835
618 618
679 679
139 139
347 347
989 989
771 771
611 611
534 534
467 467
162 162
689 689
834 834
963 963
961 961
706 706
198 198
341 341
410 410
914 914
663 663
851 851
564 564
834 834
472 472
251 251
692 692
404...

output:

098d134608c94f7413faac591054ee35
4096

result:

ok Correct answer: answer = 4096

Test #42:

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

input:

500 1 1
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
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:

098d134608c94f7413faac591054ee35
1

result:

ok Correct answer: answer = 1

Test #43:

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

input:

500 1000 500
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999
999 999...

output:

098d134608c94f7413faac591054ee35
1

result:

ok Correct answer: answer = 1

Test #44:

score: 0
Accepted
time: 20ms
memory: 5800kb

input:

500 500 123
499 499
498 498
497 497
496 496
495 495
494 494
493 493
492 492
491 491
490 490
489 489
488 488
487 487
486 486
485 485
484 484
483 483
482 482
481 481
480 480
479 479
478 478
477 477
476 476
475 475
474 474
473 473
472 472
471 471
470 470
469 469
468 468
467 467
466 466
465 465
464 464
...

output:

098d134608c94f7413faac591054ee35
2040

result:

ok Correct answer: answer = 2040

Test #45:

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

input:

500 1000 500
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
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:

098d134608c94f7413faac591054ee35
2

result:

ok Correct answer: answer = 2

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%