QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#382189#8505. Almost Alignedkevinshan#Compile Error//C++172.3kb2024-04-08 05:32:022024-04-08 05:32:02

Judging History

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

  • [2024-04-08 05:32:02]
  • 评测
  • [2024-04-08 05:32:02]
  • 提交

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-13;
    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(mn<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;
}


Details

answer.code: In function ‘int main()’:
answer.code:64:4: error: ‘mn’ was not declared in this scope; did you mean ‘m’?
   64 | if(mn<0) continue;
      |    ^~
      |    m
answer.code:14:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |         freopen("input.in", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
answer.code:15:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |         freopen("output.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~