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;
typedef long long ll;
ll take_photos(int n, int m, int k, vector<int> r, vector<int> c) {
for(int i = 0; i < n; ++i)if(r[i] > c[i])swap(r[i],c[i]);
vector<pair<int,int>> v, _v;
for(int i = 0; i < n; ++i)_v.emplace_back(r[i],c[i]);
sort(_v.begin(),_v.end());
v.push_back(_v[0]);
for(int i = 0; i < n; ++i){while(v.size()&& _v[i].first == v.back().first)v.pop_back();v.push_back(_v[i]);}
n = v.size();
if(k >= n){
ll ans = (v[0].second-v[0].first+1)*(v[0].second-v[0].first+1);
for(int i = 1; i < n; ++i){
ans+=(v[i].second-v[i].first+1)*(v[i].second-v[i].first+1);
if(v[i].first < v[i-1].second)ans-=(v[i-1].second-v[i].first+1)*(v[i-1].second-v[i].first+1);
}
return ans;
}
return 0;
}
# | 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... |