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>
#ifdef EVAL
#else
#include"grader.cpp"
#endif
using namespace std;
typedef long long ll;
bool vis[1005];
vector<int>g[1005];
ll mn,mx;
ll sq(ll a){
return a*a;
}
void dfs(int v){
vis[v]=1;
mx=max(mx,1ll*v);
mn=min(mn,1ll*v);
for(int to:g[v])if(!vis[to])dfs(to);
}
ll take_photos(int n,int m,int k,vector<int>r,vector<int>c){
sort(r.begin(),r.end());
vector<pair<int,int>>v;
for(int i=1;i<n;i++)v.push_back({r[i]-r[i-1]+1,i-1});
ll ans=0;
sort(v.begin(),v.end());
n-=k;
for(int i=0;i<n;i++){
g[v[i].second].push_back(v[i].second+1);
g[v[i].second+1].push_back(v[i].second);
}
n+=k;
for(int i=0;i<n;i++)if(!vis[i]){
mn=mx=i;
dfs(i);
mx=r[mx];
mn=r[mn];
ans+=sq(mx-mn+1);
}
return ans;
}
# | 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... |