# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
51855 | zetapi | Aliens (IOI16_aliens) | C++14 | 3 ms | 548 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "aliens.h"
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define mp make_pair
#define itr ::iterator
typedef pair<int,int> pii;
const int MAX=1e5;
const long long INF=1e12;
vector<pii> vec,lol;
bool cmp(pii X,pii Y)
{
return X.second<Y.second;
}
long long cost(int X,int Y)
{
long long side=max(vec[X-1].second,vec[Y-1].second);
side=max(side,(long long)vec[Y-1].first-vec[X-1].first+1);
return side*side;
}
long long take_photos(int n=2, int m=6, int k=2, std::vector<int> r={1,4}, std::vector<int> c={4,1})
{
long long N=n,M=m,K=k,dp[n+99][k+99];
for(int A=0;A<n;A++)
lol.pb(mp(r[A],abs(r[A]-c[A])+1));
sort(lol.begin(),lol.end());
for(int A=0;A<lol.size();A++)
{
if(A+1<lol.size() and lol[A].first==lol[A+1].first)
continue;
vec.pb((lol[A]));
}
for(int A=0;A<=N;A++)
for(int B=0;B<=K;B++)
dp[A][B]=INF;
dp[0][0]=0;
for(int A=1;A<=vec.size();A++)
{
for(int B=0;B<A;B++)
for(int C=1;C<=K;C++)
dp[A][C]=min(dp[A][C],dp[B][C-1]+cost(B+1,A));
}
long long res=INF;
for(int A=1;A<=N;A++)
for(int B=1;B<=K;B++)
res=min(res,dp[A][B]);
return res;
}
/*int main()
{
ios_base::sync_with_stdio(false);
cout<<take_photos();
return 0;
}*/
Compilation message (stderr)
# | 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... |