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<bits/stdc++.h>
#include "aliens.h"
using namespace std;
using ll = long long;
ll take_photos(int n, int m, int k, vector<int> r, vector<int> c) {
vector<pair<ll, ll>> a;
for(int i = 0; i < n; i++) {
if(r[i] > c[i]) swap(r[i], c[i]);
a.push_back({r[i], c[i]});
}
sort(a.begin(), a.end());
ll mx = 0;
ll res = 0;
for(auto [r, c] : a) {
if(c <= mx) continue;
res += (c - r + 1) * (c - r + 1);
if(mx >= r) res -= (mx - r + 1) * (mx - r + 1);
mx = max(mx, c);
}
return res;
}
# | 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... |