QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#838024#9253. Prism PalaceIllusionaryDominanceRE 0ms4168kbC++201.2kb2024-12-30 18:26:072024-12-30 18:26:08

Judging History

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

  • [2024-12-30 18:26:08]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:4168kb
  • [2024-12-30 18:26:07]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MAX_N = 200000 + 5;
const double Pi = acos(-1);

int N;
double x[MAX_N], y[MAX_N];

inline ll cross(int x1, int y1, int x2, int y2) {
    return 1ll * x1 * y2 - 1ll * y1 * x2;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    cin >> N;
    for (int i = 1; i <= N; i ++) {
        cin >> x[i] >> y[i];
    }
    if (cross(x[2] - x[1], y[2] - y[1], x[3] - x[2], y[3] - y[2]) > 0) {
        reverse(x + 1, x + N + 1);
        reverse(y + 1, y + N + 1);
    }else {
        assert(false);
    }
    double ans = 0;
    for (int i = 1; i <= N; i ++) {
        int pre = i > 1 ? i - 1 : N;
        int j = i < N ? i + 1 : 1;
        int suf = j < N ? j + 1 : 1;
        int dxl = x[i] - x[pre], dyl = y[i] - y[pre];
        int dxr = x[j] - x[suf], dyr = y[j] - y[suf]; 
        if (cross(dxl, dyl, dxr, dyr) < 0) {
            double angl = atan2(dyl, dxl);
            double angr = atan2(dyr, dxr);
            if (angl < angr) angl += Pi * 2;
            ans += (angl - angr) / Pi;
        }
    }
    cout << fixed << setprecision(12) << ans << '\n';
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
0 0
1 0
0 1

output:

1.000000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #2:

score: -100
Runtime Error

input:

4
0 0
0 1
1 1
1 0

output:


result: