QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#815840#9869. Horizon Scanningtamir#Compile Error//C++20931b2024-12-15 17:43:422024-12-15 17:43:44

Judging History

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

  • [2024-12-15 17:43:44]
  • 评测
  • [2024-12-15 17:43:42]
  • 提交

answer

#include<iostream>
#include<iomanip>
using namespace std;

double pi = acos(-1.0);
double eps = 1e-9;
void solve() {
    int n, k;
    cin >> n >> k;

    vector<pair<double, pair<int, int>>> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i].second.first >> a[i].second.second;
        a[i].first = atan2(a[i].second.first, a[i].second.second); 
    }
    if(n == 1) {
        cout << fixed << setprecision(10) << 2 * pi << '\n';
        return;
    }
    sort(a.begin(), a.end());

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

        double x = a[j].first - a[i].first;
        if(x < 0){
            x += 2 * pi;
        }
        mx = max(mx, x);
    }
    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

answer.code:5:13: error: ‘acos’ was not declared in this scope
    5 | double pi = acos(-1.0);
      |             ^~~~
answer.code: In function ‘void solve()’:
answer.code:11:5: error: ‘vector’ was not declared in this scope
   11 |     vector<pair<double, pair<int, int>>> a(n);
      |     ^~~~~~
answer.code:3:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
    2 | #include<iomanip>
  +++ |+#include <vector>
    3 | using namespace std;
answer.code:11:40: error: expected primary-expression before ‘>’ token
   11 |     vector<pair<double, pair<int, int>>> a(n);
      |                                        ^
answer.code:11:42: error: ‘a’ was not declared in this scope
   11 |     vector<pair<double, pair<int, int>>> a(n);
      |                                          ^
answer.code:14:22: error: ‘atan2’ was not declared in this scope
   14 |         a[i].first = atan2(a[i].second.first, a[i].second.second);
      |                      ^~~~~
answer.code:20:5: error: ‘sort’ was not declared in this scope; did you mean ‘short’?
   20 |     sort(a.begin(), a.end());
      |     ^~~~
      |     short