QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#150652 | #2784. Aliens | He_Ren | 0 | 1ms | 4024kb | C++17 | 1.0kb | 2023-08-25 23:02:55 | 2023-08-25 23:02:57 |
answer
#include<bits/stdc++.h>
#include "aliens.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 1e5 + 5;
const int inf = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;
ll calc(ll x,ll y)
{
return (y-x+1) * (y-x+1);
}
ll calc(array<int,2> t)
{
return calc(t[0], t[1]);
}
array<int,2> p[MAXN];
ll take_photos(int n, int, int d, vector<int> _r, vector<int> _c)
{
for(int i=1; i<=n; ++i)
{
int x = _r[i-1], y = _c[i-1];
if(x > y) swap(x, y);
p[i] = {x, y};
}
sort(p+1, p+n+1);
int nn = 0;
for(int i=1; i<=n; ++i)
{
if(nn == 0 || p[i][1] > p[nn][1])
p[++nn] = p[i];
}
n = nn;
ll ans = 0;
for(int i=1; i<=n; ++i)
ans += calc(p[i]);
while(n > d)
{
int mn = 1;
ll mnval = linf;
for(int i=1; i<n; ++i)
{
ll cur = calc(p[i][0], p[i+1][1]) - calc(p[i]) - calc(p[i+1]);
if(cur < mnval)
mn = i, mnval = cur;
}
ans += mnval;
p[mn][1] = p[mn+1][1];
for(int i=mn+1; i<n; ++i)
p[i] = p[i+1];
--n;
}
return ans;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 4
Accepted
time: 1ms
memory: 4016kb
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: 3776kb
input:
1 2 1 0 1
output:
098d134608c94f7413faac591054ee35 4
result:
ok Correct answer: answer = 4
Test #3:
score: -4
Wrong Answer
time: 1ms
memory: 3744kb
input:
2 2 2 0 0 1 0
output:
098d134608c94f7413faac591054ee35 5
result:
wrong answer Wrong answer: output = 5, expected = 4
Subtask #2:
score: 0
Wrong Answer
Test #23:
score: 12
Accepted
time: 1ms
memory: 3800kb
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: 3740kb
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: 1ms
memory: 3704kb
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: 4024kb
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: 3748kb
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: -12
Wrong Answer
time: 0ms
memory: 4020kb
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 80476
result:
wrong answer Wrong answer: output = 80476, expected = 77137
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%