QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#386934#5106. Islands from the SkyEnergy_is_not_over#AC ✓82ms4600kbC++173.5kb2024-04-11 21:44:592024-04-11 21:44:59

Judging History

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

  • [2024-04-11 21:44:59]
  • 评测
  • 测评结果:AC
  • 用时:82ms
  • 内存:4600kb
  • [2024-04-11 21:44:59]
  • 提交

answer

//
// Stvoreno ENERGom o 11.04.24. 15:22:25
//

#include <bits/stdc++.h>

#define all(a) a.begin(),a.end()
#define F first
#define fir first
#define S second
#define sec second
#define mp make_pair
#define MP make_pair
#define pb push_back
#define PB push_back

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;

#ifdef Energy
#define DEBUG for (int _____DEBUG=1;_____DEBUG;_____DEBUG=0)

template<class ...Ts>
auto &PRNT(Ts ...ts) { return ((cerr << ts << " "), ...); }

#define LOG(...) PRNT(#__VA_ARGS__" ::",__VA_ARGS__)<<endl
#else
#define DEBUG while (0)
#define LOG(...)
#endif

const int max_n = 111, inf = 1000111222;
const ld pi = 2 * acosl(0.0l);

struct Point {
    ld x, y;

    Point operator - (const Point &p) const {
        return {x - p.x, y - p.y};
    }

    Point operator + (const Point &p) const {
        return {x + p.x, y + p.y};
    }

    Point operator * (ld k) const {
        return {x * k, y * k};
    }

    Point rotate90ccw() const {
        return {-y, x};
    }

    ld len() const {
        return sqrtl(x * x + y * y);
    }
};

const ld eps = 1e-9;

int m, n;
vector<Point> poly[max_n];
ld from_z[max_n], to_z[max_n];
Point from[max_n], to[max_n];
bool ok[max_n];

ld vect_pr(const Point &a, const Point &b) {
    return a.x * b.y - a.y * b.x;
}

bool is_inside(const vector<Point> &v, const Point &p) {
    for (int i = 0; i < v.size(); ++i) {
        if (vect_pr(v[i] - p, v[(i + 1) % v.size()] - v[i]) > eps) {
            return false;
        }
    }
    return true;
}

bool check(int ind, const vector<Point> &v) {
    for (const auto p : poly[ind]) {
        if (!is_inside(v, p)) {
            return false;
        }
    }
    return true;
}

bool check(ld ang) {
    memset(ok, 0, sizeof(ok));
    const ld coef = tanl(ang);
    LOG(m);
    for (int i = 0; i < m; ++i) {
        auto dir = (to[i] - from[i]).rotate90ccw();
        dir = dir * (1.0l / dir.len());
        const ld d1 = from_z[i] * coef;
        const ld d2 = to_z[i] * coef;
        vector<Point> v{
            from[i] + dir * d1,
            to[i] + dir * d2,
            to[i] - dir * d2,
            from[i] - dir * d1
        };
        DEBUG {
            for (auto p : v) {
                cerr << p.x << " " << p.y << "   ";
            }
        };
        for (int j = 0; j < n; ++j) {
            bool f = check(j, v);
            ok[j] |= f;
            LOG(f);
        }
    }
    for (int i = 0; i < n; ++i) {
        if (!ok[i])  {
            return false;
        }
    }
    return true;
}

int main() {
//    freopen("input_f.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> m;
    LOG(n, m);
    for (int i = 0; i < n; ++i) {
        int k;
        cin >> k;
        poly[i].resize(k);
        for (int j = 0; j < k; ++j) {
            cin >> poly[i][j].x >> poly[i][j].y;
        }
    }
    for (int i = 0; i < m; ++i) {
        cin >> from[i].x >> from[i].y >> from_z[i] >> to[i].x >> to[i].y >> to_z[i];
    }
    ld l = eps, r = pi / 2 - eps;

//    LOG(check(0.1));
//    return 0;
    if (!check(r)) {
        cout << "impossible\n";
        return 0;
    }
    for (int it = 0; it < 74; ++it) {
        ld mid = (l + r) / 2;
        if (check(mid)) {
            r = mid;
        } else {
            l = mid;
        }
    }
    cout << fixed << setprecision(10) << r / pi * 180 << "\n";
    exit(0);
}

详细

Test #1:

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

input:

1 1
3
-5 0
5 0
0 5
-10 10 10 10 10 10

output:

44.9999999999

result:

ok 

Test #2:

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

input:

1 1
3
-5 0
5 0
0 5
-10 0 10 10 0 10

output:

26.5650511768

result:

ok 

Test #3:

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

input:

1 1
3
-5 0
5 0
0 5
0 10 10 10 0 10

output:

46.6861433415

result:

ok 

Test #4:

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

input:

1 1
3
-5 0
5 0
0 5
0 10 5 10 0 10

output:

59.4910411336

result:

ok 

Test #5:

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

input:

1 1
3
-5 0
5 0
0 5
0 10 20 -10 0 10

output:

31.2196984472

result:

ok 

Test #6:

score: 0
Accepted
time: 0ms
memory: 4172kb

input:

1 3
3
-5 0
5 0
0 5
-10 0 25 10 0 20
-5 10 10 10 -5 20
-4 1 100 5 10 100

output:

12.5288077090

result:

ok 

Test #7:

score: 0
Accepted
time: 0ms
memory: 4196kb

input:

1 2
4
0 0
20 0
20 40
0 40
-10 30 30 30 30 30
-10 10 30 30 10 30

output:

45.0000000000

result:

ok 

Test #8:

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

input:

1 4
4
0 0
20 0
20 40
0 40
-10 30 30 30 30 30
-10 20 30 30 20 30
-10 10 30 30 10 30
10 -10 30 10 50 30

output:

18.4349488229

result:

ok 

Test #9:

score: 0
Accepted
time: 0ms
memory: 4048kb

input:

1 2
4
0 0
40 0
40 40
0 40
10 10 10 20 20 20
30 10 10 10 30 20

output:

impossible

result:

ok 

Test #10:

score: 0
Accepted
time: 0ms
memory: 4084kb

input:

1 3
4
0 0
20 0
20 40
0 40
-10 30 30 15 30 30
5 30 30 30 30 30
1 50 30 21 50 30

output:

impossible

result:

ok 

Test #11:

score: 0
Accepted
time: 0ms
memory: 4284kb

input:

1 1
4
0 0
40 0
40 40
0 40
-100 -100 20 100 100 10

output:

63.6657521531

result:

ok 

Test #12:

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

input:

1 4
4
-10 -10
10 -10
10 10
-10 10
-100 0 10 100 0 10
0 100 10 0 -100 10
50 50 15 -50 -50 15
-50 50 15 50 -50 15

output:

43.3138566583

result:

ok 

Test #13:

score: 0
Accepted
time: 2ms
memory: 4280kb

input:

1 100
100
822286 0
856789 53904
986567 124632
629039 119995
732157 187986
691605 224716
728650 288493
591087 278144
801573 440668
425257 269876
614456 446428
424157 350893
645680 606334
406524 432904
545628 659551
359831 495265
367048 578376
251435 457360
319990 680014
336526 849968
214009 658652
23...

output:

53.7906384311

result:

ok 

Test #14:

score: 0
Accepted
time: 3ms
memory: 4460kb

input:

100 1
100
461002 481444
460618 481480
460584 481512
460833 481595
460670 481605
460545 481607
460942 481801
460526 481672
460912 481923
460765 481903
460505 481781
460430 481766
460589 481959
460593 482032
460477 481972
460440 481994
460510 482183
460285 481888
460387 482179
460246 481963
460303 482...

output:

impossible

result:

ok 

Test #15:

score: 0
Accepted
time: 17ms
memory: 4500kb

input:

100 1
100
461002 481444
460618 481480
460584 481512
460833 481595
460670 481605
460545 481607
460942 481801
460526 481672
460912 481923
460765 481903
460505 481781
460430 481766
460589 481959
460593 482032
460477 481972
460440 481994
460510 482183
460285 481888
460387 482179
460246 481963
460303 482...

output:

33.6907956097

result:

ok 

Test #16:

score: 0
Accepted
time: 15ms
memory: 4492kb

input:

100 1
100
461002 481444
460618 481480
460584 481512
460833 481595
460670 481605
460545 481607
460942 481801
460526 481672
460912 481923
460765 481903
460505 481781
460430 481766
460589 481959
460593 482032
460477 481972
460440 481994
460510 482183
460285 481888
460387 482179
460246 481963
460303 482...

output:

66.4027966421

result:

ok 

Test #17:

score: 0
Accepted
time: 80ms
memory: 4600kb

input:

100 100
100
461002 481444
460618 481480
460584 481512
460833 481595
460670 481605
460545 481607
460942 481801
460526 481672
460912 481923
460765 481903
460505 481781
460430 481766
460589 481959
460593 482032
460477 481972
460440 481994
460510 482183
460285 481888
460387 482179
460246 481963
460303 4...

output:

4.1890016471

result:

ok 

Test #18:

score: 0
Accepted
time: 53ms
memory: 4592kb

input:

100 11
100
461002 481444
460618 481480
460584 481512
460833 481595
460670 481605
460545 481607
460942 481801
460526 481672
460912 481923
460765 481903
460505 481781
460430 481766
460589 481959
460593 482032
460477 481972
460440 481994
460510 482183
460285 481888
460387 482179
460246 481963
460303 48...

output:

32.4119284772

result:

ok 

Test #19:

score: 0
Accepted
time: 82ms
memory: 4516kb

input:

100 90
100
461002 481444
460618 481480
460584 481512
460833 481595
460670 481605
460545 481607
460942 481801
460526 481672
460912 481923
460765 481903
460505 481781
460430 481766
460589 481959
460593 482032
460477 481972
460440 481994
460510 482183
460285 481888
460387 482179
460246 481963
460303 48...

output:

5.5754489360

result:

ok 

Extra Test:

score: 0
Extra Test Passed