Submission #7289792


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
typedef double db;
const db pi = acos(-1.);
db cal(const vector<pair<db, db>> &v)
{
    db a = 0, b = 0;
    for (auto x : v)
        a += x.first, b += x.second;
    return sqrt(a * a + b * b);
}
int main()
{
    int n;
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    vector<pair<pair<db, db>, db>> v(n);
    for (auto &x : v)
        cin >> x.first.first >> x.first.second, x.second = atan2(x.first.first, x.first.second);
    db ans = 0;
    for (auto x : v)
    {
        vector<pair<db, db>> va, vb;
        if (x.second >= pi)
        {
            for (auto t : v)
                if (t.second > x.second - pi && t.second < x.second)
                    va.emplace_back(t.first);
                else
                    vb.emplace_back(t.first);
            ans = max(ans, cal(va));
            ans = max(ans, cal(vb));
            va.clear();
            vb.clear();
            for (auto t : v)
                if (t.second >= x.second - pi && t.second <= x.second)
                    va.emplace_back(t.first);
                else
                    vb.emplace_back(t.first);
            ans = max(ans, cal(va));
            ans = max(ans, cal(vb));
            va.clear();
            vb.clear();
            for (auto t : v)
                if (t.second > x.second - pi && t.second <= x.second)
                    va.emplace_back(t.first);
                else
                    vb.emplace_back(t.first);
            ans = max(ans, cal(va));
            ans = max(ans, cal(vb));
            va.clear();
            vb.clear();
            for (auto t : v)
                if (t.second >= x.second - pi && t.second < x.second)
                    va.emplace_back(t.first);
                else
                    vb.emplace_back(t.first);
            ans = max(ans, cal(va));
            ans = max(ans, cal(vb));
            va.clear();
            vb.clear();
        }
        else
        {
            for (auto t : v)
                if (t.second < x.second + pi && t.second > x.second)
                    va.emplace_back(t.first);
                else
                    vb.emplace_back(t.first);
            ans = max(ans, cal(va));
            ans = max(ans, cal(vb));
            va.clear();
            vb.clear();
            for (auto t : v)
                if (t.second <= x.second + pi && t.second >= x.second)
                    va.emplace_back(t.first);
                else
                    vb.emplace_back(t.first);
            ans = max(ans, cal(va));
            ans = max(ans, cal(vb));
            va.clear();
            vb.clear();
            for (auto t : v)
                if (t.second < x.second + pi && t.second >= x.second)
                    va.emplace_back(t.first);
                else
                    vb.emplace_back(t.first);
            ans = max(ans, cal(va));
            ans = max(ans, cal(vb));
            va.clear();
            vb.clear();
            for (auto t : v)
                if (t.second <= x.second + pi && t.second > x.second)
                    va.emplace_back(t.first);
                else
                    vb.emplace_back(t.first);
            ans = max(ans, cal(va));
            ans = max(ans, cal(vb));
            va.clear();
            vb.clear();
        }
    }
    vector<pair<db, db>> va, vb;
    for (auto x : v)
        if (x.first.first > 0)
            va.emplace_back(x.first);
        else
            vb.emplace_back(x.first);
    ans = max(cal(va), ans);
    ans = max(cal(vb), ans);
    va.clear();
    vb.clear();
    for (auto x : v)
        if (x.first.first >= 0)
            va.emplace_back(x.first);
        else
            vb.emplace_back(x.first);
    ans = max(cal(va), ans);
    ans = max(cal(vb), ans);
    va.clear();
    vb.clear();
    for (auto x : v)
        if (x.first.second > 0)
            va.emplace_back(x.first);
        else
            vb.emplace_back(x.first);
    ans = max(cal(va), ans);
    ans = max(cal(vb), ans);
    va.clear();
    vb.clear();
    for (auto x : v)
        if (x.first.second >= 0)
            va.emplace_back(x.first);
        else
            vb.emplace_back(x.first);
    ans = max(cal(va), ans);
    ans = max(cal(vb), ans);
    va.clear();
    vb.clear();
    cout << fixed << setprecision(20) << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task F - Engines
User WA_King
Language C++14 (GCC 5.4.1)
Score 0
Code Size 4501 Byte
Status WA
Exec Time 2 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 7
AC × 40
WA × 1
Set Name Test Cases
Sample 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 00-sample-04.txt, 00-sample-05.txt, 00-sample-06.txt, 00-sample-07.txt
All 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 00-sample-04.txt, 00-sample-05.txt, 00-sample-06.txt, 00-sample-07.txt, 01-random-very-small-01.txt, 01-random-very-small-02.txt, 01-random-very-small-03.txt, 02-random-small-01.txt, 02-random-small-02.txt, 02-random-small-03.txt, 03-random-01.txt, 03-random-02.txt, 03-random-03.txt, 04-zero-01.txt, 05-same-01.txt, 05-same-02.txt, 06-linear-01.txt, 06-linear-02.txt, 06-linear-03.txt, 07-linear-positive-01.txt, 07-linear-positive-02.txt, 07-linear-positive-03.txt, 08-90-degree-01.txt, 08-90-degree-02.txt, 09-180-degree-01.txt, 09-180-degree-02.txt, 10-sandglass-01.txt, 10-sandglass-02.txt, 11-circle-01.txt, 11-circle-02.txt, 11-circle-03.txt, 11-circle-04.txt, 11-circle-05.txt, 12-square-01.txt, 12-square-02.txt, 12-square-03.txt, 13-corner-01.txt, 13-corner-02.txt
Case Name Status Exec Time Memory
00-sample-01.txt AC 1 ms 256 KB
00-sample-02.txt AC 1 ms 256 KB
00-sample-03.txt AC 1 ms 256 KB
00-sample-04.txt AC 1 ms 256 KB
00-sample-05.txt AC 1 ms 256 KB
00-sample-06.txt AC 1 ms 256 KB
00-sample-07.txt AC 1 ms 256 KB
01-random-very-small-01.txt AC 1 ms 256 KB
01-random-very-small-02.txt AC 2 ms 256 KB
01-random-very-small-03.txt AC 2 ms 256 KB
02-random-small-01.txt AC 1 ms 256 KB
02-random-small-02.txt WA 2 ms 256 KB
02-random-small-03.txt AC 2 ms 256 KB
03-random-01.txt AC 1 ms 256 KB
03-random-02.txt AC 2 ms 256 KB
03-random-03.txt AC 2 ms 256 KB
04-zero-01.txt AC 2 ms 256 KB
05-same-01.txt AC 2 ms 256 KB
05-same-02.txt AC 2 ms 256 KB
06-linear-01.txt AC 1 ms 256 KB
06-linear-02.txt AC 1 ms 256 KB
06-linear-03.txt AC 2 ms 256 KB
07-linear-positive-01.txt AC 1 ms 256 KB
07-linear-positive-02.txt AC 1 ms 256 KB
07-linear-positive-03.txt AC 2 ms 256 KB
08-90-degree-01.txt AC 2 ms 256 KB
08-90-degree-02.txt AC 2 ms 256 KB
09-180-degree-01.txt AC 1 ms 256 KB
09-180-degree-02.txt AC 2 ms 256 KB
10-sandglass-01.txt AC 1 ms 256 KB
10-sandglass-02.txt AC 2 ms 256 KB
11-circle-01.txt AC 1 ms 256 KB
11-circle-02.txt AC 1 ms 256 KB
11-circle-03.txt AC 1 ms 256 KB
11-circle-04.txt AC 1 ms 256 KB
11-circle-05.txt AC 2 ms 256 KB
12-square-01.txt AC 2 ms 256 KB
12-square-02.txt AC 2 ms 256 KB
12-square-03.txt AC 2 ms 256 KB
13-corner-01.txt AC 1 ms 256 KB
13-corner-02.txt AC 1 ms 256 KB