QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#488087 | #6676. Computational Geometry | duyhoanho | AC ✓ | 20ms | 5340kb | C++20 | 1.7kb | 2024-07-23 16:20:34 | 2024-07-23 16:20:35 |
Judging History
answer
// fannhkn
#include<bits/stdc++.h>
#define forinc(i,a,b) for(int i=a;i<=b;i++)
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
using namespace std;
const int N=1e5+10;
int n,k;
pii a[N];
double xuli(pii x,pii y)
{
return x.fi * y.se - x.se * y.fi;
}
void sol()
{
cin>>n>>k;
forinc(i,0,n-1) cin>>a[i].fi>>a[i].se;
double res=0;
int b=0;
int c=k;
int x=-1;
double tmp=0;
for(int i=1;i<=c;i++) tmp+=xuli(a[i-1],a[i]);
for(int i=n-1 ; i != c ; i--)
{
double S = tmp + xuli(a[c],a[i]) + xuli(a[i] , a[b]);
if(S>res)
{
res=S;
x=i;
}
}
forinc(i,1,n-1)
{
c=(c+1)%n;
tmp+=xuli(a[(c - 1 + n) % n] , a[c]) - xuli(a[b] , a[(b+1)%n]);
b = (b + 1) % n;
if(x==c) x=(c+1)%n;
double pre = tmp + xuli(a[c],a[x]) + xuli(a[x],a[b]);
while(x!=b)
{
x=(x+1)%n;
if(x==b)
{
x=(b-1+n)%n;
break;
}
if(pre<tmp + xuli(a[c],a[x]) + xuli(a[x],a[b])) pre=tmp + xuli(a[c],a[x]) + xuli(a[x],a[b]);
else
{
x=(x-1+n)%n;
break;
}
}
res=max(res,pre);
}
cout << setprecision(12) << res/2 << '\n';
//forinc(i,(l+1)%n , r)
}
int32_t main()
{
#define task "task"
if(fopen(task".inp","r"))
{
freopen(task".inp","r",stdin);
freopen(task".out","w",stdout);
}
ios_base::sync_with_stdio(false);
cin.tie(0);
int t;cin>>t;
while(t--)
{
sol();
}
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3824kb
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: 3928kb
input:
1 4 2 -1000000000 -1000000000 1000000000 -1000000000 1000000000 1000000000 -1000000000 1000000000
output:
4e+18
result:
ok found '4000000000000000000.000000000', expected '4000000000000000000.000000000', error '0.000000000'
Test #3:
score: 0
Accepted
time: 18ms
memory: 3828kb
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: 20ms
memory: 3884kb
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:
7.32791354437e+17 1.49246691691e+18 1.5716086248e+18 8.53722168332e+17 1.8415795558e+18 1.86812625651e+17 1.37493137382e+18 1.39624876653e+18 3.00749428982e+17 1.5976809776e+18 2.38431782745e+17 1.90562106187e+18 1.45705188574e+18 7.72319614795e+17 1.67143877612e+17 1.25519417341e+18 1.23597408927e+...
result:
ok 14244 numbers
Test #5:
score: 0
Accepted
time: 17ms
memory: 3696kb
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:
2.90182908405e+18 3.27527198347e+17 1.73425602996e+18 2.41638086504e+18 9.35891084318e+17 2.82841470396e+18 2.10146069481e+18 2.42693153237e+18 2.67937253466e+18 2.76236128172e+18 1.17686406301e+18 2.67417597527e+18 4.15161195169e+17 1.31571112265e+18 2.28203837371e+18 1.18594861918e+18 1.7176396632...
result:
ok 1000 numbers
Test #6:
score: 0
Accepted
time: 16ms
memory: 3708kb
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:
1.02892355272e+18 2.83230177986e+18 2.84801124747e+18 2.50679018499e+18 2.62237787525e+18 2.55638123348e+18 2.78039690909e+18 1.7355318991e+18 9.87263293126e+17 2.93385896519e+18 1.94074812016e+18 2.86713036157e+18 2.74706958628e+18 2.75180739115e+18 4.62785130841e+16 1.17377360504e+18 2.95634825698...
result:
ok 100 numbers
Test #7:
score: 0
Accepted
time: 17ms
memory: 3992kb
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:
2.09590870604e+18 2.88150990642e+18 8.60651843538e+17 2.22524052161e+18 9.11084696371e+17 2.13447096584e+18 2.92416838263e+18 1.0529945308e+18 2.55568063518e+18 2.70324147129e+18
result:
ok 10 numbers
Test #8:
score: 0
Accepted
time: 13ms
memory: 5340kb
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:
2.8899870644e+18
result:
ok found '2889987064400000000.000000000', expected '2889987064399269888.000000000', error '0.000000000'