QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#750661#9576. Ordainer of Inexorable JudgmentUESTC_DECAYALI#Compile Error//C++176.9kb2024-11-15 15:23:132024-11-15 15:23:14

Judging History

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

  • [2024-12-23 14:23:26]
  • hack成功,自动添加数据
  • (/hack/1303)
  • [2024-12-06 11:32:56]
  • hack成功,自动添加数据
  • (/hack/1271)
  • [2024-11-15 15:23:14]
  • 评测
  • [2024-11-15 15:23:13]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
using LD = long double;

const LD eps = 1e-8;
const LD PI = acosl(-1.0L);

LD sqr(LD x) {return x*x;}
int sgn(LD x) {return fabs(x)<=eps ? 0 : (x>eps ? 1 : -1);}

struct Point {
    LD x, y;
    LD operator^(const Point &b) const {return x*b.y - y*b.x;}
    LD operator*(const Point &b) const {return x*b.x + y*b.y;}
    bool operator<(const Point &b) const {return sgn((*this)^b) > 0;}
    Point operator*(const LD &b) const {return Point{x*b, y*b};}
    Point operator+(const Point &b) const {return Point{x+b.x, y+b.y};}
    Point operator-(const Point &b) const {return Point{x-b.x, y-b.y};}
    LD len() const {return sqrtl(x*x+y*y);}
    LD len2() const {return x*x+y*y;}
    Point rot(const LD &cosr, const LD &sinr) {
        return {x*cosr - y*sinr, x*sinr + y*cosr};
    }
    LD ang(const Point &a) const {
        return atan2l((*this)^a, (*this)*a);
    }
}; 

LD p_seg_dis2(Point p, Point a, Point b) {
    if (sgn((p-a)*(b-a))<=0 && sgn((p-b)*(a-b))<=0) 
        return min((a-p).len2(), (b-p).len2());
    Point v = b-a;
    LD res = abs(v ^ (p-a)) / v.len();
    return sqr(res);
}

struct Circle {
    Point c;
    LD r;

    pair<Point, Point> tangent(const Point &a) const {
        Point e = a-c;
        e = e * (r / e.len());
        const LD costh = r / (c-a).len(), sinth = sqrtl(1 - sqr(costh));
        const Point t1 = c + e.rot(costh, -sinth), t2 = c + e.rot(costh, sinth);
        return {t1, t2};
    }
};

int n, xx0, yy0, d;
LD t;
Circle cir;
vector<Point> conv;

signed main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    cin >> n >> xx0 >> yy0 >> d >> t;
    cir = Circle{{0.0L, 0.0L}, (LD)d};
    conv.reserve(n);
    for (int i=0; i<n; ++i) {
        int x, y; cin >> x >> y;
        conv.push_back(Point{(LD)x, (LD)y});
    }

    bool ok = false;
    for (int i=0; i<n; ++i) {
        if (sgn(sqr(d) - p_seg_dis2({0, 0}, conv[i], conv[(i+1)%n])) >= 0) {
            ok = true; break;
        }
    }

    bool flag = true;
    for (int i=0; i<n; ++i) {
        if (sgn((conv[(i+1)%n]-conv[i])^(Point{0, 0}-conv[i])) < 0) {
            flag = false; break;
        }
    }
    if (flag) ok=true;

    if (ok) {
        cout << t << '\n';
        return 0;
    }

    vector<Point> vt1, vt2;
    for (int i=0; i<n; ++i) {
        auto [t1, t2] = cir.tangent(conv[i]);
        vt1.push_back(t1);
        vt2.push_back(t2);
    }

    auto findmn = [&](vector<Point> &vec){
        auto res = vec[0];
        for (auto p : vec) res = min(res, p);
        return res;
    };
    auto findmx = [&](vector<Point> &vec){
        auto res = vec[0];
        for (auto p : vec) res = max(res, p);
        return res;
    };

    auto t1 = findmx(vt1);
    auto t2 = findmn(vt2);
    auto rt1 = t1.rot(0, 1), rt2 = t2.rot(0, -1);
    LD ang = rt2.ang(rt1);

    LD ans = 0.0L;
    int round = floor(t / (2*PI) + eps);
    ans += round * ang;
    t -= round*2*PI;

    Point v = Point{xx0, yy0};
    LD th2 = v.ang(rt2); if (sgn(th2) < 0) th2 = 2*PI+th2;
    LD th1 = v.ang(rt1); if (sgn(th1) < 0) th1 = 2*PI+th1;
    // printf("th2=%Lf th1=%Lf\n", th2, th1);

    if (sgn(rt2^v)>0 && sgn(v^rt1)>0) {
        if (t < th1) ans += t;
        else ans += th1 + (sgn(t-th2)>=0 ? t-th2 : 0);
    } else {
        if (t > th2) ans += min(th1, t) - th2;
    }
    cout << ans << '\n';
    return 0;
}#include<bits/stdc++.h>
using namespace std;
#define int long long
using LD = long double;

const LD eps = 1e-8;
const LD PI = acosl(-1.0L);

LD sqr(LD x) {return x*x;}
int sgn(LD x) {return fabs(x)<=eps ? 0 : (x>eps ? 1 : -1);}

struct Point {
    LD x, y;
    LD operator^(const Point &b) const {return x*b.y - y*b.x;}
    LD operator*(const Point &b) const {return x*b.x + y*b.y;}
    bool operator<(const Point &b) const {return sgn((*this)^b) > 0;}
    Point operator*(const LD &b) const {return Point{x*b, y*b};}
    Point operator+(const Point &b) const {return Point{x+b.x, y+b.y};}
    Point operator-(const Point &b) const {return Point{x-b.x, y-b.y};}
    LD len() const {return sqrtl(x*x+y*y);}
    LD len2() const {return x*x+y*y;}
    Point rot(const LD &cosr, const LD &sinr) {
        return {x*cosr - y*sinr, x*sinr + y*cosr};
    }
    LD ang(const Point &a) const {
        return atan2l((*this)^a, (*this)*a);
    }
}; 

LD p_seg_dis2(Point p, Point a, Point b) {
    if (sgn((p-a)*(b-a))<=0 && sgn((p-b)*(a-b))<=0) 
        return min((a-p).len2(), (b-p).len2());
    Point v = b-a;
    LD res = abs(v ^ (p-a)) / v.len();
    return sqr(res);
}

struct Circle {
    Point c;
    LD r;

    pair<Point, Point> tangent(const Point &a) const {
        Point e = a-c;
        e = e * (r / e.len());
        const LD costh = r / (c-a).len(), sinth = sqrtl(1 - sqr(costh));
        const Point t1 = c + e.rot(costh, -sinth), t2 = c + e.rot(costh, sinth);
        return {t1, t2};
    }
};

int n, xx0, yy0, d;
LD t;
Circle cir;
vector<Point> conv;

signed main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    cin >> n >> xx0 >> yy0 >> d >> t;
    cir = Circle{{0.0L, 0.0L}, (LD)d};
    conv.reserve(n);
    for (int i=0; i<n; ++i) {
        int x, y; cin >> x >> y;
        conv.push_back(Point{(LD)x, (LD)y});
    }

    bool ok = false;
    for (int i=0; i<n; ++i) {
        if (sgn(sqr(d) - p_seg_dis2({0, 0}, conv[i], conv[(i+1)%n])) >= 0) {
            ok = true; break;
        }
    }

    bool flag = true;
    for (int i=0; i<n; ++i) {
        if (sgn((conv[(i+1)%n]-conv[i])^(Point{0, 0}-conv[i])) < 0) {
            flag = false; break;
        }
    }
    if (flag) ok=true;

    if (ok) {
        cout << t << '\n';
        return 0;
    }

    vector<Point> vt1, vt2;
    for (int i=0; i<n; ++i) {
        auto [t1, t2] = cir.tangent(conv[i]);
        vt1.push_back(t1);
        vt2.push_back(t2);
    }

    auto findmn = [&](vector<Point> &vec){
        auto res = vec[0];
        for (auto p : vec) res = min(res, p);
        return res;
    };
    auto findmx = [&](vector<Point> &vec){
        auto res = vec[0];
        for (auto p : vec) res = max(res, p);
        return res;
    };

    auto t1 = findmx(vt1);
    auto t2 = findmn(vt2);
    auto rt1 = t1.rot(0, 1), rt2 = t2.rot(0, -1);
    LD ang = rt2.ang(rt1);

    LD ans = 0.0L;
    int round = floor(t / (2*PI) + eps);
    ans += round * ang;
    t -= round*2*PI;

    Point v = Point{xx0, yy0};
    LD th2 = v.ang(rt2); if (sgn(th2) < 0) th2 = 2*PI+th2;
    LD th1 = v.ang(rt1); if (sgn(th1) < 0) th1 = 2*PI+th1;
    // printf("th2=%Lf th1=%Lf\n", th2, th1);

    if (sgn(rt2^v)>0 && sgn(v^rt1)>0) {
        if (t < th2) ans += t;
        else ans += th2 + (t > th1 ? t-th1 : 0);
    } else ans += min(th1, t) - th2;
    cout << ans << '\n';
    return 0;
}

详细

answer.code:128:2: error: stray ‘#’ in program
  128 | }#include<bits/stdc++.h>
      |  ^
answer.code: In function ‘int main()’:
answer.code:115:21: warning: narrowing conversion of ‘xx0’ from ‘long long int’ to ‘LD’ {aka ‘long double’} [-Wnarrowing]
  115 |     Point v = Point{xx0, yy0};
      |                     ^~~
answer.code:115:26: warning: narrowing conversion of ‘yy0’ from ‘long long int’ to ‘LD’ {aka ‘long double’} [-Wnarrowing]
  115 |     Point v = Point{xx0, yy0};
      |                          ^~~
answer.code: At global scope:
answer.code:128:3: error: ‘include’ does not name a type
  128 | }#include<bits/stdc++.h>
      |   ^~~~~~~
answer.code:133:10: error: redefinition of ‘const LD eps’
  133 | const LD eps = 1e-8;
      |          ^~~
answer.code:6:10: note: ‘const LD eps’ previously defined here
    6 | const LD eps = 1e-8;
      |          ^~~
answer.code:134:10: error: redefinition of ‘const LD PI’
  134 | const LD PI = acosl(-1.0L);
      |          ^~
answer.code:7:10: note: ‘const LD PI’ previously defined here
    7 | const LD PI = acosl(-1.0L);
      |          ^~
answer.code:136:4: error: redefinition of ‘LD sqr(LD)’
  136 | LD sqr(LD x) {return x*x;}
      |    ^~~
answer.code:9:4: note: ‘LD sqr(LD)’ previously defined here
    9 | LD sqr(LD x) {return x*x;}
      |    ^~~
answer.code:137:5: error: redefinition of ‘long long int sgn(LD)’
  137 | int sgn(LD x) {return fabs(x)<=eps ? 0 : (x>eps ? 1 : -1);}
      |     ^~~
answer.code:10:5: note: ‘long long int sgn(LD)’ previously defined here
   10 | int sgn(LD x) {return fabs(x)<=eps ? 0 : (x>eps ? 1 : -1);}
      |     ^~~
answer.code:139:8: error: redefinition of ‘struct Point’
  139 | struct Point {
      |        ^~~~~
answer.code:12:8: note: previous definition of ‘struct Point’
   12 | struct Point {
      |        ^~~~~
answer.code:157:4: error: redefinition of ‘LD p_seg_dis2(Point, Point, Point)’
  157 | LD p_seg_dis2(Point p, Point a, Point b) {
      |    ^~~~~~~~~~
answer.code:30:4: note: ‘LD p_seg_dis2(Point, Point, Point)’ previously defined here
   30 | LD p_seg_dis2(Point p, Point a, Point b) {
      |    ^~~~~~~~~~
answer.code:165:8: error: redefinition of ‘struct Circle’
  165 | struct Circle {
      |        ^~~~~~
answer.code:38:8: note: previous definition of ‘struct Circle’
   38 | struct Circle {
      |        ^~~~~~
answer.code:178:5: error: redefinition of ‘long long int n’
  178 | int n, xx0, yy0, d;
      |     ^
answer.code:51:5: note: ‘long long int n’ previously declared here
   51 | int n, xx0, yy0, d;
      |     ^
answer.code:178:8: error: redefinition of ‘long long int xx0’
  178 | int n, xx0, yy0, d;
      |        ^~~
answer.code:51:8: note: ‘long long int xx0’ previously declared here
   51 | int n, xx0, yy0, d;
      |        ^~~
answer.code:178:13: error: redefinition of ‘long long int yy0’
  178 | int n, xx0, yy0, d;
      |             ^~~
answer.code:51:13: note: ‘long long int yy0’ previously declared here
   51 | int n, xx0, yy0, d;
      |             ^~~
answer.code:178:18: error: redefinition of ‘long long int d’
  178 | int n, xx0, yy0, d;
      |                  ^
answer.code:51:18: note: ‘long long int d’ previously declared here
   51 | int n, xx0, yy0, d;
      |                  ^
answer.code:179:4: error: redefinition of ‘LD t’
  179 | LD t;
      |    ^
answer.code:52:4: note: ‘LD t’ previously declared here
   52 | LD t;
      |    ^
answer.code:180:8: error: redefinition of ‘Circle cir’
  180 | Circle cir;
      |        ^~~
answer.code:53:8: note: ‘Circle cir’ previously declared here
   53 | Circle cir;
      |        ^~~
answer.code:181:15: error: redefinition of ‘std::vector<Point> conv’
  181 | vector<Point> conv;
      |               ^~~~
answer.code:54:15: note: ‘std::vector<Point> conv’ previously declared here
   54 | vector<Point> conv;
      |               ^~~~
answer.code:183:8: error: redefinition of ‘int main()’
  183 | signed main() {
      |        ^~~~
answer.code:56:8: note: ‘int main()’ previously defined here
   56 | signed main() {
      |        ^~~~
answer.code: In function ‘int main()’:
answer.code:242:21: warning: narrowing conversion of ‘xx0’ from ‘long long int’ to ‘LD’ {aka ‘long double’} [-Wnarrowing]
  242 |     Point v = Point{xx0, yy0};
      |                     ^~~
answer.code:242:26: warning: narrowing conversion of ‘yy0’ from ‘long long int’ to ‘LD’ {aka ‘long double’} [-Wnarrowing]
  242 |     Point v = Point{xx0, yy0};
      |                          ^~~