Submission #347458

#TimeUsernameProblemLanguageResultExecution timeMemory
347458juggernautAliens (IOI16_aliens)C++14
0 / 100
1 ms364 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...