이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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++)
for(int j=0;j<n;j++)if(r[i]==r[j])g[i].push_back(j);
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... |