QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#151441#6118. EartheartSommohito#Compile Error//C++205.1kb2023-08-26 17:33:242023-08-26 17:33:25

Judging History

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

  • [2023-08-26 17:33:25]
  • 评测
  • [2023-08-26 17:33:24]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#ifdef APURBA
#include "DEBUG_TEMPLATE.h"
#else
#define HERE
#define debug(args...)
#endif
#define ALL(x) x.begin(),x.end()

const double eps=1e-9;

inline int dcmp (double x) { if (fabs(x) < 1e-9) return 0; else return x < 0 ? -1 : 1; }

struct PT {
 double x, y;
 PT (double x = 0, double y = 0): x(x), y(y) {}
 void read () { scanf("%lf%lf", &x, &y); }
 void write () { printf("%lf %lf", x, y); }
 bool operator == (const PT& u) const { return dcmp(x - u.x) == 0 && dcmp(y - u.y) == 0; }
 bool operator != (const PT& u) const { return !(*this == u); }
 bool operator < (const PT& u) const { return dcmp(x - u.x) < 0 || (dcmp(x-u.x)==0 && dcmp(y-u.y) < 0); }
 bool operator > (const PT& u) const { return u < *this; }
 bool operator <= (const PT& u) const { return *this < u || *this == u; }
 bool operator >= (const PT& u) const { return *this > u || *this == u; }
 PT operator + (const PT& u) { return PT(x + u.x, y + u.y); }
 PT operator - (const PT& u) { return PT(x - u.x, y - u.y); }
 PT operator * (const double u) { return PT(x * u, y * u); }
 PT operator / (const double u) { return PT(x / u, y / u); }
 double operator * (const PT& u) { return x*u.y - y*u.x; }
};

inline double cross(PT a, PT b) { return a.x * b.y - a.y * b.x; }
inline double cross2(PT a, PT b, PT c) { return cross(b - a, c - a); }

bool is_point_on_seg(PT a, PT b, PT p) {
 if (fabs(cross(p - b, a - b)) < eps) {
  if (p.x < min(a.x, b.x) || p.x > max(a.x, b.x)) return false;
  if (p.y < min(a.y, b.y) || p.y > max(a.y, b.y)) return false;
  return true;
 }
 return false;
}
bool seg_seg_intersection(PT a, PT b, PT c, PT d, PT &ans) {
 double oa = cross2(c, d, a), ob = cross2(c, d, b);
 double oc = cross2(a, b, c), od = cross2(a, b, d);
 if (oa * ob < 0 && oc * od < 0){
  ans = (a * ob - b * oa) / (ob - oa);
  return 1;
 }
 else return 0;
}
set<PT> seg_seg_intersection_inside(PT a,  PT b,  PT c,  PT d) {
 PT ans;
 if (seg_seg_intersection(a, b, c, d, ans)) return {ans};
 set<PT> se;
 if (is_point_on_seg(c, d, a)) se.insert(a);
 if (is_point_on_seg(c, d, b)) se.insert(b);
 if (is_point_on_seg(a, b, c)) se.insert(c);
 if (is_point_on_seg(a, b, d)) se.insert(d);
 return se;
}
#define Pt PT
#define Vector PT
struct Circle {
 Pt o;double r;
 Circle () {}
 Circle (Pt o, double r = 0): o(o), r(r) {}
 void read () { o.read(), scanf("%lf", &r); }
 Pt pt(double rad) { return Pt(o.x + cos(rad)*r, o.y + sin(rad)*r); }
 double getArea (double rad) { return rad * r * r / 2; }
 //area of the circular sector cut by a chord with central angle alpha
 double sector(double alpha) {return r * r * 0.5 * (alpha - sin(alpha));}
};
 int getLineCircleIntersection (Pt p, Pt q, Circle O, double& t1, double& t2, vector<Pt>& sol) {
  Vector v = q - p;
  //sol.clear();
  double a = v.x, b = p.x - O.o.x, c = v.y, d = p.y - O.o.y;
  double e = a*a+c*c, f = 2*(a*b+c*d), g = b*b+d*d-O.r*O.r;
  double delta = f*f - 4*e*g;
  if (dcmp(delta) < 0) return 0;
  if (dcmp(delta) == 0) {
   t1 = t2 = -f / (2 * e);
   sol.push_back(p + v * t1);
   return 1;
  }
  t1 = (-f - sqrt(delta)) / (2 * e); sol.push_back(p + v * t1);
  t2 = (-f + sqrt(delta)) / (2 * e); sol.push_back(p + v * t2);
  return 2;
 }

void check( vector<PT>& fig) {
    ll res = 0;
    for (unsigned i = 0; i < fig.size(); i++) {
        PT p = i ? fig[i - 1] : fig.back();
        PT q = fig[i];
        res += (p.x - q.x) * (p.y + q.y);
    }
    if(res<0)
        reverse(fig.begin(),fig.end());
}

int n,R;
vector<PT>v;
vector<pair<ld,int>>pq;



void maro(PT A,PT B)
{
    if(abs(A.second)>abs(B.second))
        swap(A,B);
    ld vx=B.x-A.x,vy=B.y-A.y;
    if(A.second>=R)
        return;
    ld low=0,high=1;
    int cnt=200;
    while(cnt--)
    {
        ld mid=(low+high)/2;
        PT temp=A;
        temp.x+=vx*mid;
        temp.y+=vy*mid;
        
    }
}

void TEST_CASES()
{
    cin>>n>>R;
    v.resize(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i].x>>v[i].y;
    }
    check(v);


    for(int i=0;i<n;i++)
    {
        if(v[i].y==0&&v[(i+1)%n].y==0)
        {
            maro(v[i],v[(i+1)%n]);
            continue;
        }
        auto where=seg_seg_intersection_inside(v[i],v[(i+1)%n],PT(-1e9,0),PT(1e9,0));
        if(where.size()==0)
        {
            maro(v[i],v[(i+1)%n]);
            continue;
        }

        auto which=*where.begin();
        if(v[i].y<v[(i+1)%n].y)
        {
            pq.push_back({-which.x,0});
            debug(i,which.x,0);
        }
        else
        {
            pq.push_back({-which.x,1});
            debug(i,which.x,1);
        }
        maro(v[i],which);
        maro(which,v[(i+1)%n]);
    }



}


/*
*/

int32_t main()
{
#ifndef APURBA
    ios_base::sync_with_stdio(false);
    cin.tie(nullPTr);
#endif
    //freopen("input.txt","r",stdin);
    //freopen("out1.txt","w",stdout);
    int t=1;
    //cin>>t;
    while(t--)
    {
        TEST_CASES();
    }
    return 0;
}

Details

answer.code: In function ‘void maro(PT, PT)’:
answer.code:113:14: error: ‘struct PT’ has no member named ‘second’
  113 |     if(abs(A.second)>abs(B.second))
      |              ^~~~~~
answer.code:113:28: error: ‘struct PT’ has no member named ‘second’
  113 |     if(abs(A.second)>abs(B.second))
      |                            ^~~~~~
answer.code:116:10: error: ‘struct PT’ has no member named ‘second’
  116 |     if(A.second>=R)
      |          ^~~~~~
answer.code: In function ‘int32_t main()’:
answer.code:182:13: error: ‘nullPTr’ was not declared in this scope; did you mean ‘nullptr_t’?
  182 |     cin.tie(nullPTr);
      |             ^~~~~~~
      |             nullptr_t