QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#49192 | #4601. Vale of Eternal | ckiseki# | AC ✓ | 61ms | 5536kb | C++ | 2.2kb | 2022-09-19 17:12:00 | 2022-09-19 17:12:03 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
using PT = pair<int,int>;
int64_t cross(pair<int,int> a, pair<int,int> b, pair<int,int> c) {
return 1LL * (c.first - b.first) * (b.second - a.second) - 1LL * (c.second - b.second) * (b.first - a.first);
}
vector<pair<int,int>> CV(vector<pair<int,int>> p) {
sort(p.begin(), p.end());
if (p[0] == p.back()) return {p[0]};
int n = p.size(), t = 0;
vector<pair<int,int>> h(n + 1);
for (int _ = 2, s = 0; _--; s = --t, reverse(p.begin(), p.end())) {
for (pair<int,int> i: p) {
while (t > s + 1 && cross(i, h[t-1], h[t-2]) >= 0)
--t;
h[t++] = i;
}
}
return h.resize(t), h;
}
template <typename V>
int64_t area(const V &pt) {
int64_t ret = 0;
for (int i = 1; i + 1 < (int)pt.size(); i++) {
pair<int,int> A(pt[i].first-pt[0].first, pt[i].second-pt[0].second);
pair<int,int> B(pt[i+1].first-pt[0].first, pt[i+1].second-pt[0].second);
ret += 1LL * A.first * B.second - 1LL * A.second * B.first;
}
return abs(ret);
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int T;
cin >> T;
while (T--) {
int n, q;
cin >> n >> q;
vector<pair<int,int>> cv(n);
for (auto &[x, y]: cv) {
cin >> x >> y;
tie(x, y) = pair{x+y, x-y};
}
int mxX = 0, mxY = 0;
int mnX = 1e9, mnY = 1e9;
for (auto &[x, y]: cv) {
mxX = max(mxX, x);
mnX = min(mnX, x);
mxY = max(mxY, y);
mnY = min(mnY, y);
}
cv = CV(cv);
// for (auto p: cv) {
// cerr << "p = " << p.first << ' ' << p.second << '\n';
// }
int64_t B = (mxX - mnX) + (mxY - mnY);
int64_t A = area(cv);
assert (A % 2 == 0);
A /= 2;
cout << fixed << setprecision(1);
for (int i = 0; i < q; i++) {
int64_t t;
cin >> t;
cout << A / 2 + B * t + 2 * t * t;
if (A & 1)
cout << ".5";
else
cout << ".0";
cout << '\n';
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 61ms
memory: 5536kb
input:
11 3 3 2 3 4 3 1 1 1 2 3 3 3 4 1 3 4 2 1 2 3 4 10 10 37 76 71 57 66 82 85 85 21 12 94 70 60 6 68 52 2 68 29 53 19 21 46 9 99 65 44 90 50 21 10 10 26 21 77 57 38 96 80 94 5 74 95 53 58 99 50 54 74 25 29 4 54 74 50 51 82 100 15 77 42 64 10 10 14 97 5 89 37 42 36 94 67 68 20 92 42 61 67 77 53 44 99 92 ...
output:
11.0 24.0 41.0 27.0 45.0 67.0 10297.0 10971.0 20746.0 7167.0 49737.0 29847.0 19872.0 44022.0 22542.0 10971.0 25391.0 35691.0 23523.0 23984.0 40259.0 51473.0 9908.0 37374.0 19979.0 30341.0 33215.5 41660.5 28085.5 33750.5 17010.5 4032.5 12239.5 22904.5 32684.5 29582.5 45013.5 5764.5 26279.5 9208.5 170...
result:
ok 203046 lines