QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#715161#9576. Ordainer of Inexorable Judgmentucup-team1196Compile Error//C++235.8kb2024-11-06 10:39:162024-11-06 10:39:16

Judging History

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

  • [2024-12-23 14:23:26]
  • hack成功,自动添加数据
  • (/hack/1303)
  • [2024-12-06 11:32:56]
  • hack成功,自动添加数据
  • (/hack/1271)
  • [2024-11-14 21:58:28]
  • hack成功,自动添加数据
  • (/hack/1181)
  • [2024-11-06 10:39:16]
  • 评测
  • [2024-11-06 10:39:16]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define double long double

const double PI = acos(-1);
struct Point {
    int x, y;
    Point(int x_ = 0, int y_ = 0) : x(x_), y(y_) {}

    friend std::istream& operator >> (std::istream& is, Point& a) {
        return is >> a.x >> a.y;
    }
};

void solve() {
    int n, d, t;
    Point o(0, 0), f;
    std::cin >> n >> f >> d >> t;
    std::vector<Point> ps(n + 1);
    for (int i = 1; i <= n; i++) {
        std::cin >> ps[i];
    }

    std::cout << std::fixed << std::setprecision(12);

    auto [X, Y] = f;
    double init = std::acos(X / std::sqrt(X * X + Y * Y));
    if (Y < 0) {
        init = 2 * PI - init;
    }

    auto change = [&](double x) {
        if (x < 0) {
            return 2 * PI + x;
        } else {
            return x;
        }
    };
    const double EPS = 1e-8;

    std::vector<std::pair<double, double>> v;

    auto cal = [&](int x, int y) {
        double D = std::sqrt(x * x + y * y);
        double EQ = 1. * d / D;
        double Cos = y / D;
        double alpha = std::acos(Cos);
        if (x < 0) {
            alpha = 2 * PI - alpha;
        }
        double ang = asin(EQ);
        double L = ang - alpha;
        double R = PI - alpha - ang;
        L = change(L);
        R = change(R);
        L -= init;
        R -= init;
        while (L < EPS) {
            L += 2 * PI;
        }
        while (R < EPS) {
            R += 2 * PI;
        }
        while (L > 2 * PI - EPS) {
            L -= 2 * PI;
        }
        while (R > 2 * PI - EPS) {
            R -= 2 * PI;
        }
        if (R < L) {
            std::swap(L, R);
        }
        if (R - L >= PI) {
            v.push_back({R - 2 * PI, L});
        } else {
            v.push_back({L, R});
        }
    };

    for (int i = 1; i <= n; i++) {
        auto [x, y] = ps[i];
        if (x * x + y * y <= d * d) {
            // std::cout << 1. * t << '\n';
            return;
        }
        cal(x, y);
    }

    double lst = 0;

    int whole = t / (2 * PI);
    double rem = t - whole * 2 * PI;

    double T = 2 * PI;

    double ma = -1e18, mi = 1e18;
    for (auto [L, R] : v) {
        // std::cout << L << ' ' << R << '\n';
        ma = std::max(ma, L);
        mi = std::min(mi, R);
    }

    // std::cout << "Before " << mi << ' ' << ma << '\n';

    mi -= PI / 2;
    ma += PI / 2;

    if (ma < mi) {
        std::swap(mi, ma);
    }

    // std::cout << mi << ' ' << ma << '\n';
    T = ma - mi;

    double pre = std::max((double)0.,std::min(ma, rem) - std::max((double)0., mi));
    double bac = std::max((double)0., rem - mi - 2 * PI);
    double Rem = pre + bac;

    std::cout << whole * T + Rem << '\n';
}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    // freopen("M.in", "r", stdin);

    int t = 1;
    // std::cin >> t;

    while (t --) {
        solve();
    }
}
    Point(int x_ = 0, int y_ = 0) : x(x_), y(y_) {}

    friend std::istream& operator >> (std::istream& is, Point& a) {
        return is >> a.x >> a.y;
    }
};

void solve() {
    int n, d, t;
    Point o(0, 0), f;
    std::cin >> n >> f >> d >> t;
    std::vector<Point> ps(n + 1);
    for (int i = 1; i <= n; i++) {
        std::cin >> ps[i];
    }

    // std::cout << std::fixed << std::setprecision(12);

    auto [X, Y] = f;
    double init = std::acos(X / std::sqrt(X * X + Y * Y));
    if (Y < 0) {
        init = 2 * PI - init;
    }

    auto change = [&](double x) {
        if (x < 0) {
            return 2 * PI + x;
        } else {
            return x;
        }
    };
    const double EPS = 1e-8;

    std::vector<std::pair<double, double>> v;

    auto cal = [&](int x, int y) {
        double D = std::sqrt(x * x + y * y);
        double EQ = 1. * d / D;
        double Cos = y / D;
        double alpha = std::acos(Cos);
        if (x < 0) {
            alpha = 2 * PI - alpha;
        }
        double ang = asin(EQ);
        double L = ang - alpha;
        double R = PI - alpha - ang;
        L = change(L);
        R = change(R);
        L -= init;
        R -= init;
        while (L < EPS) {
            L += 2 * PI;
        }
        while (R < EPS) {
            R += 2 * PI;
        }
        while (L > 2 * PI - EPS) {
            L -= 2 * PI;
        }
        while (R > 2 * PI - EPS) {
            R -= 2 * PI;
        }
        if (R < L) {
            std::swap(L, R);
        }
        if (R - L >= PI) {
            v.push_back({R - 2 * PI, L});
        } else {
            v.push_back({L, R});
        }
    };

    for (int i = 1; i <= n; i++) {
        auto [x, y] = ps[i];
        if (x * x + y * y <= d * d) {
            // std::cout << 1. * t << '\n';
            return;
        }
        cal(x, y);
    }

    double lst = 0;

    int whole = t / (2 * PI);
    double rem = t - whole * 2 * PI;

    double T = 2 * PI;

    double ma = -1e18, mi = 1e18;
    for (auto [L, R] : v) {
        // std::cout << L << ' ' << R << '\n';
        ma = std::max(ma, L);
        mi = std::min(mi, R);
    }

    // std::cout << "Before " << mi << ' ' << ma << '\n';

    mi -= PI / 2;
    ma += PI / 2;

    if (ma < mi) {
        std::swap(mi, ma);
    }

    // std::cout << mi << ' ' << ma << '\n';
    T = ma - mi;

    double pre = std::max((double)0.,std::min(ma, rem) - std::max((double)0., mi));
    double bac = std::max((double)0., rem - mi - 2 * PI);
    double Rem = pre + bac;

    std::cout << whole * T + Rem << '\n';
}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    // freopen("M.in", "r", stdin);

    int t = 1;
    // std::cin >> t;

    while (t --) {
        solve();
    }
}

详细

answer.code:138:5: error: ISO C++ forbids declaration of ‘Point’ with no type [-fpermissive]
  138 |     Point(int x_ = 0, int y_ = 0) : x(x_), y(y_) {}
      |     ^~~~~
answer.code: In function ‘int Point(long long int, long long int)’:
answer.code:138:37: error: only constructors take member initializers
  138 |     Point(int x_ = 0, int y_ = 0) : x(x_), y(y_) {}
      |                                     ^
answer.code:138:51: warning: no return statement in function returning non-void [-Wreturn-type]
  138 |     Point(int x_ = 0, int y_ = 0) : x(x_), y(y_) {}
      |                                                   ^
answer.code: At global scope:
answer.code:140:5: error: ‘friend’ used outside of class
  140 |     friend std::istream& operator >> (std::istream& is, Point& a) {
      |     ^~~~~~
      |     ------
answer.code:140:57: error: ‘Point’ is not a type
  140 |     friend std::istream& operator >> (std::istream& is, Point& a) {
      |                                                         ^~~~~
answer.code: In function ‘std::istream& operator>>(std::istream&, int&)’:
answer.code:141:24: error: request for member ‘x’ in ‘a’, which is of non-class type ‘int’
  141 |         return is >> a.x >> a.y;
      |                        ^
answer.code:141:31: error: request for member ‘y’ in ‘a’, which is of non-class type ‘int’
  141 |         return is >> a.x >> a.y;
      |                               ^
answer.code: At global scope:
answer.code:143:1: error: expected declaration before ‘}’ token
  143 | };
      | ^
answer.code:145:6: error: redefinition of ‘void solve()’
  145 | void solve() {
      |      ^~~~~
answer.code:18:6: note: ‘void solve()’ previously defined here
   18 | void solve() {
      |      ^~~~~
answer.code: In function ‘void solve()’:
answer.code:147:10: error: expected ‘;’ before ‘o’
  147 |     Point o(0, 0), f;
      |          ^~
      |          ;
answer.code:148:22: error: ‘f’ was not declared in this scope
  148 |     std::cin >> n >> f >> d >> t;
      |                      ^
answer.code:149:22: error: type/value mismatch at argument 1 in template parameter list for ‘template<class _Tp, class _Alloc> class std::vector’
  149 |     std::vector<Point> ps(n + 1);
      |                      ^
answer.code:149:22: note:   expected a type, got ‘Point’
answer.code:149:22: error: template argument 2 is invalid
answer.code:151:23: error: invalid types ‘int[long long int]’ for array subscript
  151 |         std::cin >> ps[i];
      |                       ^
answer.code:211:25: error: invalid types ‘int[long long int]’ for array subscript
  211 |         auto [x, y] = ps[i];
      |                         ^
answer.code: At global scope:
answer.code:253:8: error: redefinition of ‘int main()’
  253 | signed main() {
      |        ^~~~
answer.code:126:8: note: ‘int main()’ previously defined here
  126 | signed main() {
      |        ^~~~
answer.code:46:16: error: mangling of ‘solve()::<lambda(long long int, long long int)>’ as ‘_ZZ5solvevENKUlxxE_clExx’ conflicts with a previous mangle
   46 |     auto cal = [&](int x, int y) {
      |                ^
answer.code:173:16: note: previous mangling ‘solve()::<lambda(long long int, long long int)>’
  173 |     auto cal = [&](int x, int y) {
      |                ^
answer.code:46:16: note: a later ‘-fabi-version=’ (or =0) avoids this error with a change in mangling
   46 |     auto cal = [&](int x, int y) {
      |                ^