QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#816056#9869. Horizon Scanningtamir#WA 26ms4232kbC++201.9kb2024-12-15 21:29:562024-12-15 21:29:56

Judging History

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

  • [2024-12-15 21:29:56]
  • 评测
  • 测评结果:WA
  • 用时:26ms
  • 内存:4232kb
  • [2024-12-15 21:29:56]
  • 提交

answer

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

using ll = long long;
double pi = acos(-1.0);
double eps = 1e-9;

bool check(pair<int, int> a, pair<int, int> b){
    vector<bool> ispos(4);
    if(a.first >= 0)ispos[0] = true;
    if(a.second >= 0)ispos[1] = true;
    if(b.first >= 0)ispos[2] = true;
    if(b.second >= 0)ispos[3] = true;

    return (ispos[0] == ispos[2] && ispos[1] == ispos[3]);   
}
void solve() {
    int n, k;
    cin >> n >> k;

    vector<pair<pair<ll, ll>, int>> pos, neg; 
    vector<ll> x(n), y(n);
    

    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
        if(y[i] >= 0)pos.push_back({{x[i], y[i]}, i});
        else neg.push_back({{x[i], y[i]}, i});
    }

    sort(pos.begin(), pos.end(), [&](const pair<pair<ll, ll>, int> &xx, const pair<pair<ll, ll>, int> &yy){
       return (xx.first.first * yy.first.second > xx.first.second * yy.first.first); 
    });
    sort(neg.begin(), neg.end(), [&](const pair<pair<ll, ll>, int> &xx, const pair<pair<ll, ll>, int> &yy){
       return (xx.first.first * yy.first.second > xx.first.second * yy.first.first); 
    });

    for(auto t : neg){
        pos.push_back(t);
    }
    
    if(pos.front().first.first * pos.back().first.second == pos.front().first.second * pos.back().first.first && check(pos.front().first, pos.back().first)){
        cout << fixed << setprecision(10) << pi * 2 << '\n';

        return;
    }
    double mx = 0.0;

    for(int i = 0; i < n; i++) {
        int j = (i + k) % n;

        double w1 = atan2(pos[j].first.second, pos[j].first.first) - atan2(pos[i].first.second, pos[i].first.first);
        
        if(w1 < 0.0){
            w1 += 2 * pi;
        }
        
        mx = max(mx, w1);
    }
    cout << fixed << setprecision(10) << mx << '\n';
}

int main() {
    ios::sync_with_stdio(0); cin.tie(nullptr);
    int t = 1;
    cin >> t;
    while(t--) {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 4232kb

input:

5
1 1
0 1
8 2
1 0
1 1
0 1
-1 1
-1 0
-1 -1
0 -1
1 -1
4 2
-1 1
0 1
0 2
1 1
4 2
-1000000000 0
-998244353 1
998244353 1
1000000000 0
3 1
0 1
0 2
0 -1

output:

6.2831853072
1.5707963268
5.4977871438
3.1415926546
3.1415926536

result:

ok 5 numbers

Test #2:

score: -100
Wrong Answer
time: 26ms
memory: 4124kb

input:

10000
16 1
-10 -6
-5 -6
-4 9
-2 5
-2 10
1 -7
1 -5
1 6
3 1
4 -9
6 -10
6 -3
6 1
8 -5
8 -4
9 -4
17 4
-9 2
-8 -4
-8 -3
-8 -1
-6 -2
-6 -1
-6 8
-5 -8
-5 10
-4 8
-2 -8
4 -9
4 0
5 -3
8 -5
9 -2
10 10
10 6
-7 2
-4 6
-2 -7
-2 -1
-1 7
1 -9
1 8
3 -4
7 -4
9 -2
14 3
-9 10
-8 -10
-8 -8
-6 -7
-6 -5
-1 -7
-1 -2
0 -1
...

output:

1.6929914975
2.5748634361
4.6527582673
2.7726331074
5.7427658069
4.8576989910
3.4198923126
2.8127999621
0.0000000000
0.0000000000
5.1172807667
6.1467827028
3.8420890235
2.3424967168
3.4633432080
0.0000000000
5.9614347528
3.3247034709
5.2627749281
5.6724593428
1.6738779353
1.1141908549
2.4087775518
0...

result:

wrong answer 9th numbers differ - expected: '6.2831853', found: '0.0000000', error = '1.0000000'