QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#118039 | #6676. Computational Geometry | UndertrainedOverpressure# | AC ✓ | 17ms | 6212kb | C++23 | 2.5kb | 2023-07-02 22:53:07 | 2023-07-02 22:53:09 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define TIME (clock() * 1.0 / CLOCKS_PER_SEC)
// _________ vect (2D) ______________
template <typename T>
struct vect {
T x = 0;
T y = 0;
vect() = default;
vect(T x_, T y_) : x(x_), y(y_) {}
inline T len2() const {
return x * x + y * y;
}
inline ld len() const {
return sqrtl(len2());
}
inline vect rotate() const {
return vect(-y, x);
}
};
template <typename T>
inline istream& operator>>(istream& in, vect<T>& v) {
return in >> v.x >> v.y;
}
template <typename T>
inline ostream& operator<<(ostream& out, const vect<T>& v) {
return out << "[" << v.x << "," << v.y << "]";
}
template <typename T>
inline vect<T> operator+(const vect<T>& a, const vect<T>& b) {
return vect(a.x + b.x, a.y + b.y);
}
template <typename T>
inline vect<T> operator-(const vect<T>& a, const vect<T>& b) {
return vect(a.x - b.x, a.y - b.y);
}
template <typename T>
inline vect<T> operator*(const vect<T>& a, T k) {
return vect(a.x * k, a.y * k);
}
template <typename T>
inline T operator*(const vect<T>& a, const vect<T>& b) {
return a.x * b.x + a.y * b.y;
}
template <typename T>
inline T operator^(const vect<T>& a, const vect<T>& b) {
return a.x * b.y - a.y * b.x;
}
void solve() {
int n, k;
cin >> n >> k;
vector<vect<ll>> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i];
}
vector<ll> pref(2 * n + 1, 0);
for (int i = 0; i < 2 * n; i++) {
pref[i + 1] = pref[i] + (v[i % n] ^ (v[(i + 1) % n]));
}
auto calc_area = [&](int l, int r) {
if (l <= r) {
return pref[r] - pref[l] + (v[r] ^ v[l]);
}
return pref[r + n] - pref[l] + (v[r] ^ v[l]);
};
ll ans = 0;
int st = k;
for (int i = 0; i < n; i++) {
int j = (i + k) % n;
while (((v[(st + 1) % n] - v[st]) ^ (v[j] - v[i])) <= 0) {
st = (st + 1) % n;
}
ans = max(ans, pref[n] - calc_area(st, i) - calc_area(j, st));
//cerr << i + 1 << " " << j + 1 << " " << st + 1 << "\n";
}
cout << (ans / 2);
if (ans % 2 == 1) {
cout << ".5";
}
cout << "\n";
}
int main() {
#ifdef ONPC
freopen("input", "r", stdin);
#endif
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3460kb
input:
3 3 1 0 0 1 0 0 1 8 3 1 2 3 1 5 1 7 3 8 6 5 8 3 7 1 5 7 2 3 6 1 1 3 1 7 1 8 1 5 6 4 6
output:
0.5 26.5 20
result:
ok 3 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3432kb
input:
1 4 2 -1000000000 -1000000000 1000000000 -1000000000 1000000000 1000000000 -1000000000 1000000000
output:
4000000000000000000
result:
ok found '4000000000000000000.000000000', expected '4000000000000000000.000000000', error '0.000000000'
Test #3:
score: 0
Accepted
time: 15ms
memory: 3444kb
input:
14246 7 5 -999999980 -999999988 -999999979 -999999984 -999999978 -999999978 -999999979 -999999972 -1000000000 -999999998 -999999993 -1000000000 -999999984 -999999993 6 1 -999999987 -999999987 -999999993 -999999981 -999999998 -999999986 -1000000000 -999999996 -999999995 -1000000000 -999999986 -999999...
output:
230.5 78 173 46 161.5 25 224 78 42 75 113.5 179 227 224.5 459.5 33.5 323 208 14 117 261.5 162.5 136 227.5 91 376 81 502.5 179.5 141 346.5 41 90.5 209 118 183 406.5 49.5 80.5 222.5 394 243 114 402 245.5 386 106 75 297.5 424 269 104 216 174.5 260.5 157.5 610.5 45 50 519.5 516.5 113.5 161 522.5 67.5 55...
result:
ok 14246 numbers
Test #4:
score: 0
Accepted
time: 13ms
memory: 3420kb
input:
14244 6 4 -547850284 -481269250 -1000000000 -714647423 -533299247 -1000000000 656886478 -769438616 700263718 -430440203 106399420 -305601756 10 3 -466281822 506862192 -907094238 85058839 -1000000000 -281869646 -855490497 -478229011 -112167057 -1000000000 147495199 -983428035 704507845 -902383045 828...
output:
732791354437434402.5 1492466916906283434.5 1571608624804175410 853722168331793629.5 1841579555796117823.5 186812625650844482 1374931373816256616 1396248766527417139.5 300749428982044501 1597680977600300477 238431782745048669.5 1905621061870671069.5 1457051885738670384.5 772319614795252917 1671438776...
result:
ok 14244 numbers
Test #5:
score: 0
Accepted
time: 17ms
memory: 3392kb
input:
1000 100 84 -638427072 -696806030 -574275620 -741577840 -517724956 -779879773 -440790977 -831653888 -371696794 -867523797 -292070733 -904513365 -246157947 -920874374 -196125497 -936669098 -120139525 -960537360 -54479671 -978537127 -11534554 -987883373 26411313 -994847568 72263671 -1000000000 1168709...
output:
2901829084045602653.5 327527198347053245.5 1734256029955228808 2416380865036326542 935891084317887469 2828414703961765312 2101460694807832700 2426931532374706265 2679372534658023503.5 2762361281720090419 1176864063012644015 2674175975267185443.5 415161195168528653 1315711122651032242 228203837370924...
result:
ok 1000 numbers
Test #6:
score: 0
Accepted
time: 9ms
memory: 3444kb
input:
100 1000 168 -808847262 -517721134 -803072067 -525448193 -798730847 -531136476 -796502549 -534032203 -791151313 -540928191 -786588703 -546785604 -782732315 -551644783 -780071973 -554976222 -774771946 -561591700 -769683918 -567839156 -769554831 -567997637 -766249149 -572042373 -759870835 -579831042 -...
output:
1028923552719996045 2832301779860078526 2848011247470070271 2506790184987356823.5 2622377875251076131 2556381233480029365.5 2780396909089778369.5 1735531899101324156.5 987263293126023982 2933858965189297928 1940748120157040436 2867130361573929234 2747069586277213982 2751807391149625902 4627851308409...
result:
ok 100 numbers
Test #7:
score: 0
Accepted
time: 14ms
memory: 3520kb
input:
10 10000 3930 374998960 871320826 374305646 871707307 373541784 872131442 372913079 872480119 372247815 872848960 372082544 872940283 371300533 873371391 370696772 873703715 369897687 874143282 369135422 874562333 368787728 874753324 368396307 874968013 367915968 875230945 367376687 875525844 367147...
output:
2095908706043761789 2881509906421599358 860651843537664107 2225240521612313977.5 911084696371304608 2134470965837802211 2924168382633125311.5 1052994530795952349.5 2555680635181519967 2703241471286160570.5
result:
ok 10 numbers
Test #8:
score: 0
Accepted
time: 10ms
memory: 6212kb
input:
1 100000 91077 937469288 -231959258 937491476 -231891836 937502721 -231857664 937522226 -231798381 937545631 -231727224 937556752 -231693411 937581626 -231617767 937594048 -231579990 937605611 -231544822 937620487 -231499574 937644936 -231425160 937656870 -231388830 937680141 -231317975 937699154 -2...
output:
2889987064399269902
result:
ok found '2889987064399269888.000000000', expected '2889987064399269888.000000000', error '0.000000000'