QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#382194#8505. Almost Alignedkevinshan#WA 0ms3972kbC++172.3kb2024-04-08 05:36:062024-04-08 05:36:07

Judging History

你现在查看的是最新测评结果

  • [2024-04-08 05:36:07]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3972kb
  • [2024-04-08 05:36:06]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define ll long double
#define all(x) x.begin(), x.end()
#define pb push_back
#define f first
#define s second

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int n; cin>>n;
    ll x[n], y[n], vx[n], vy[n];
    for(int i=0; i<n; i++) cin>>x[i]>>y[i]>>vx[i]>>vy[i];

    ll l = 0;
    ll r = 2e9;
    ll delta = 1e-16;
    ll ar = 3e18;
    while(r - l >= delta) {
        ll m = (l+r)/2.0;
        ll mnx = x[0] + vx[0] * m;
        ll mxx = x[0] + vx[0] * m;
        ll mny = y[0] + vy[0] * m;
        ll mxy = y[0] + vy[0] * m;
        for(int i=1; i<n; i++){
            mnx = min(mnx, x[i] + vx[i] * m);
            mxx = max(mxx, x[i] + vx[i] * m);
            mny = min(mny, y[i] + vy[i] * m);
            mxy = max(mxy, y[i] + vy[i] * m);
        }

        ll md = m + delta;

        ll mnxd = x[0] + vx[0] * md;
        ll mxxd = x[0] + vx[0] * md;
        ll mnyd = y[0] + vy[0] * md;
        ll mxyd = y[0] + vy[0] * md;
        for(int i=1; i<n; i++){
            mnxd = min(mnxd, x[i] + vx[i] * md);
            mxxd = max(mxxd, x[i] + vx[i] * md);
            mnyd = min(mnyd, y[i] + vy[i] * md);
            mxyd = max(mxyd, y[i] + vy[i] * md);
        }

        if((mxx - mnx) * (mxy - mny) > (mxxd - mnxd) * (mxyd - mnyd) + delta){
            l = m;
        }
        else {
            r = m;
        }
        // cout<<l<<"|"<<r<<"\n";
        // cout<<(mxx - mnx) * (mxy - mny)<<"\n";
        ar = min(ar, (mxx - mnx) * (mxy - mny));
        ar = min(ar, (mxxd - mnxd) * (mxyd - mnyd));
    }
    for(int i=-50; i<=50; i++){
        ll m = i * delta + l;
        if(m<0) continue;
        ll mnx = x[0] + vx[0] * m;
        ll mxx = x[0] + vx[0] * m;
        ll mny = y[0] + vy[0] * m;
        ll mxy = y[0] + vy[0] * m;
        for(int i=1; i<n; i++){
            mnx = min(mnx, x[i] + vx[i] * m);
            mxx = max(mxx, x[i] + vx[i] * m);
            mny = min(mny, y[i] + vy[i] * m);
            mxy = max(mxy, y[i] + vy[i] * m);
        }
        ar = min(ar, (mxx - mnx) * (mxy - mny));
    }
    cout<<fixed<<setprecision(25)<<ar;
}


详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3700kb

input:

4
0 0 10 10
0 0 10 10
10 10 -10 -10
10 0 -20 0

output:

22.2222222222222233756205867

result:

ok found '22.222222222', expected '22.222222222', error '0.000000000'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3908kb

input:

3
0 -1 0 2
1 1 1 1
-1 1 -1 1

output:

0.0000000000000001066854938

result:

ok found '0.000000000', expected '0.000000000', error '0.000000000'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

3
0 -1 0 -2
1 1 1 1
-1 1 -1 1

output:

4.0000000000000000000000000

result:

ok found '4.000000000', expected '4.000000000', error '0.000000000'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3972kb

input:

1
0 0 0 0

output:

0.0000000000000000000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3796kb

input:

4
1000000 1000000 -1 -1000000
1000000 -1000000 -1000000 1
-1000000 -1000000 1 1000000
-1000000 1000000 1000000 -1

output:

3999985098852.6839401721954345703125000

result:

wrong answer 1st numbers differ - expected: '3999984000032.0000000', found: '3999985098852.6840820', error = '0.0000003'