# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
432019 |
2021-06-17T19:08:26 Z |
Tangent |
Aliens (IOI16_aliens) |
C++17 |
|
1 ms |
204 KB |
#include "aliens.h"
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vii> vvii;
typedef vector<vll> vvll;
typedef vector<vpii> vvpii;
typedef vector<vpll> vvpll;
#define ffor(i, a, b) for (ll i = (a); i < (ll)(b); i++)
#define fford(i, a, b) for (ll i = (a); i > (ll)(b); i--)
#define rep(i, n) ffor(i, 0, n)
#define forin(x, a) for (auto &x: a)
#define all(a) a.begin(), a.end()
#define sq(x) (x) * (x)
long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> cc) {
vpii intervals;
rep(i, n) {
if (r[i] > cc[i]) {
swap(r[i], cc[i]);
}
intervals.emplace_back(r[i], -cc[i]);
}
sort(all(intervals));
vpii merged = {{intervals[0].first, -intervals[0].second}};
ffor(i, 1, intervals.size()) {
if (-intervals[i].second > merged.back().second) {
merged.emplace_back(intervals[i].first, -intervals[i].second);
}
}
while ((int)merged.size() > k) {
int besti = 0;
ll mincost = 1ll << 62;
rep(i, merged.size() - 1) {
int a, b, c, d;
tie(a, b) = merged[i];
tie(c, d) = merged[i + 1];
ll cost = sq(d - a + 1) - sq(b - a + 1) - sq(d - c + 1) + sq(max(0, b - c + 1));
if (cost < mincost) {
mincost = cost;
besti = i;
}
}
merged[besti].second = merged[besti + 1].second;
merged.erase(merged.begin() + besti + 1);
}
ll res = sq(merged[0].second - merged[0].first + 1);
rep(i, merged.size() - 1) {
int a, b, c, d;
tie(a, b) = merged[i];
tie(c, d) = merged[i + 1];
res += sq(d - c + 1) - sq(max(0, b - c + 1));
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
2 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 4 |
3 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
4 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 12 |
5 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 52 |
6 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 210 |
7 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 88 |
8 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7696 |
9 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 1 |
10 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 2374 |
11 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 9502 |
12 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 49 |
13 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 151 |
14 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7550 |
15 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7220 |
16 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7550 |
17 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 10000 |
18 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 10000 |
19 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 624 |
20 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 10000 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 1 |
2 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
3 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 1 |
4 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 5 |
5 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 41 |
6 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 71923 |
7 |
Incorrect |
1 ms |
204 KB |
Wrong answer: output = 80476, expected = 77137 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
2 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 4 |
3 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
4 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 12 |
5 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 52 |
6 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 210 |
7 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 88 |
8 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7696 |
9 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 1 |
10 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 2374 |
11 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 9502 |
12 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 49 |
13 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 151 |
14 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7550 |
15 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7220 |
16 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7550 |
17 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 10000 |
18 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 10000 |
19 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 624 |
20 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 10000 |
21 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 1 |
22 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
23 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 1 |
24 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 5 |
25 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 41 |
26 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 71923 |
27 |
Incorrect |
1 ms |
204 KB |
Wrong answer: output = 80476, expected = 77137 |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
2 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 4 |
3 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
4 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 12 |
5 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 52 |
6 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 210 |
7 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 88 |
8 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7696 |
9 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 1 |
10 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 2374 |
11 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 9502 |
12 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 49 |
13 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 151 |
14 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7550 |
15 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7220 |
16 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7550 |
17 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 10000 |
18 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 10000 |
19 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 624 |
20 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 10000 |
21 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 1 |
22 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
23 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 1 |
24 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 5 |
25 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 41 |
26 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 71923 |
27 |
Incorrect |
1 ms |
204 KB |
Wrong answer: output = 80476, expected = 77137 |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
2 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 4 |
3 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
4 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 12 |
5 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 52 |
6 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 210 |
7 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 88 |
8 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7696 |
9 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 1 |
10 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 2374 |
11 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 9502 |
12 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 49 |
13 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 151 |
14 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7550 |
15 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7220 |
16 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7550 |
17 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 10000 |
18 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 10000 |
19 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 624 |
20 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 10000 |
21 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 1 |
22 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
23 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 1 |
24 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 5 |
25 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 41 |
26 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 71923 |
27 |
Incorrect |
1 ms |
204 KB |
Wrong answer: output = 80476, expected = 77137 |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
2 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 4 |
3 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
4 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 12 |
5 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 52 |
6 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 210 |
7 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 88 |
8 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7696 |
9 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 1 |
10 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 2374 |
11 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 9502 |
12 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 49 |
13 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 151 |
14 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7550 |
15 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7220 |
16 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 7550 |
17 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 10000 |
18 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 10000 |
19 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 624 |
20 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 10000 |
21 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 1 |
22 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 4 |
23 |
Correct |
0 ms |
204 KB |
Correct answer: answer = 1 |
24 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 5 |
25 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 41 |
26 |
Correct |
1 ms |
204 KB |
Correct answer: answer = 71923 |
27 |
Incorrect |
1 ms |
204 KB |
Wrong answer: output = 80476, expected = 77137 |
28 |
Halted |
0 ms |
0 KB |
- |