# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
223646 | DedMaxim | Aliens (IOI16_aliens) | C++17 | 0 ms | 0 KiB |
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>
long long INF = 2e9;
long long cost(int r, int l) {
return (r - l + 1) * 1ll * (r - l + 1);
}
bool points_comparartor(const std::pair<int, int>& a, const std::pair<int, int>& b) {
return (a.first == b.first) ? (a.second > b.second) : (a.first < b.first);
}
long long take_photos(int n, int m, int k, const std::vector<int>& r, const std::vector<int>& c) {
std::vector<std::vector<bool>> used(m, std::vector<bool>(m, false));
for (int i = 1; i <= n; ++i) {
for (int x = r[i]; x <= c[i]; ++x) {
for (int y = r[i]; y <= c[i]; ++y) {
used[x][y] = true;
}
}
}
long long result = 0;
for (int x = 0; x != m; ++x) {
for (int y = 0; y != m; ++y) {
result += used[x][y];
}
}
return result;
}
int main() {
int n, m, k;
assert(3 == scanf("%d %d %d", &n, &m, &k));
std::vector<int> r(n + 1), c(n + 1);
for (int i = 1; i <= n; i++) {
assert(2 == scanf("%d %d", &r[i], &c[i]));
if (r[i] > c[i]) {
std::swap(r[i], c[i]);
}
}
long long ans = take_photos(n, m, k, r, c);
printf("%lld\n", ans);
return 0;
}