QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#552917#9253. Prism Palaceucup-team3617#WA 31ms7312kbC++20983b2024-09-08 04:00:522024-09-08 04:00:52

Judging History

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

  • [2024-09-08 04:00:52]
  • 评测
  • 测评结果:WA
  • 用时:31ms
  • 内存:7312kb
  • [2024-09-08 04:00:52]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int MN = 200005;
const double PI = atan(1) * 4;

int n;
pair<int, int> a[MN], vec[MN];
#define x first
#define y second

double mag(pair<int, int> vec) {
    return sqrt(vec.x * vec.x + vec.y * vec.y);
}

double dot(pair<int, int> v1, pair<int, int> v2) {
    return v1.x * v2.x + v1.y * v2.y;
}

double get_angle(int i) {
    double prod = dot(vec[i], vec[(i+1)%n]) / (mag(vec[i]) * mag(vec[(i+1)%n]));
    return acos(-prod);
}

int main() {
    cin.tie(0), cin.sync_with_stdio(0);
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i].x >> a[i].y;
    for (int i = 0; i < n; i++) {
        vec[i].x = a[(i+1)%n].x - a[i].x;
        vec[i].y = a[(i+1)%n].y - a[i].y;
    }
    double ans = 0;
    for (int i = 0; i < n; i++) {
        double sum = get_angle(i) + get_angle((i + 1) % n);
        if (sum > PI) continue;
        ans += PI - sum;
    }
    printf("%.9f\n", ans / PI);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
0 0
1 0
0 1

output:

1.000000000

result:

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

Test #2:

score: 0
Accepted
time: 1ms
memory: 3916kb

input:

4
0 0
0 1
1 1
1 0

output:

0.000000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #3:

score: 0
Accepted
time: 1ms
memory: 6172kb

input:

4
0 0
0 3
1 2
1 1

output:

0.500000000

result:

ok found '0.5000000', expected '0.5000000', error '0.0000000'

Test #4:

score: -100
Wrong Answer
time: 31ms
memory: 7312kb

input:

199996
719157942 80035870
719158808 80033199
719160795 80027070
719162868 80020675
719165635 80012139
719166422 80009711
719166927 80008153
719168388 80003645
719168539 80003179
719168806 80002355
719168864 80002176
719169119 80001389
719171067 79995376
719173806 79986921
719175195 79982633
71917686...

output:

nan

result:

wrong output format Expected double, but "nan" found