이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "aliens.h"
#include<bits/stdc++.h>
using namespace std;
const int MN=500+10;
long long inf;
long long dp[MN][MN];
pair<int,int> p[MN];
long long sq(int x){
return 1ll*x*x;
}
bool g[MN][MN];
long long take_photos(int n, int m, int k, vector<int> r, vector<int> c) {
inf=1ll*m*m;
for(int i=0;i<n;i++){
p[i]={min(r[i],c[i]),-max(r[i],c[i])-1};
}
sort(p,p+n);
int n1=unique(p,p+n)-p;
n=0;
int mx=-1;
for(int i=0;i<n1;i++){
if(mx<-p[i].second){
p[n++]={p[i].first,-p[i].second};
mx=p[i].second;
}
}
long long ans=0;
for(int i=0;i<n;i++){
if(g[p[i].first][p[i].second-1]){
return -1;
}
for(int j=p[i].first;j<p[i].second;j++){
for(int k=p[i].first;k<p[i].second;k++){
if(g[j][k]==0){
g[j][k]=1;
ans++;
}
}
}
}
return ans;
for(int i=0;i<n;i++){
for(int j=0;j<=k;j++){
dp[i+1][j]=inf;
for(int l=0;l<=i;l++){
if(j){
if(l==0){
dp[i+1][j]=min(dp[i+1][j],sq(p[i].second-p[l].first)+dp[l][j-1]);
}
else{
dp[i+1][j]=min(dp[i+1][j],dp[l][j-1]+sq(p[i].second-p[l].first)-sq(max(0,p[l-1].second-p[l].first)));
}
}
}
}
}
return dp[n][k];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |