QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#131898#2784. Aliensvalerikk#0 1ms6072kbC++171.5kb2023-07-28 21:22:382024-07-04 01:01:20

Judging History

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

  • [2024-07-04 01:01:20]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:6072kb
  • [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:22:38]
  • 提交

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 (r1 > r[n - 1]) {
			while (n > 1 && r[n - 1] >= 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: 6024kb

input:

2 6 2
1 4
4 1

output:

098d134608c94f7413faac591054ee35
16

result:

ok Correct answer: answer = 16

Test #2:

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

input:

1 2 1
0 1

output:

098d134608c94f7413faac591054ee35
4

result:

ok Correct answer: answer = 4

Test #3:

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

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: 5724kb

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: 6052kb

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: 1ms
memory: 5764kb

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: 0
Wrong Answer

Test #23:

score: 12
Accepted
time: 1ms
memory: 5764kb

input:

2 2 1
0 0
1 1

output:

098d134608c94f7413faac591054ee35
4

result:

ok Correct answer: answer = 4

Test #24:

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

input:

4 3 2
0 0
0 0
0 0
0 0

output:

098d134608c94f7413faac591054ee35
1

result:

ok Correct answer: answer = 1

Test #25:

score: -12
Wrong Answer
time: 1ms
memory: 5792kb

input:

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

output:

098d134608c94f7413faac591054ee35
2

result:

wrong answer Wrong answer: output = 2, expected = 5

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%