QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#358755#5106. Islands from the SkynvmdavaAC ✓48ms4108kbC++233.7kb2024-03-19 23:37:412024-03-19 23:37:42

Judging History

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

  • [2024-03-19 23:37:42]
  • 评测
  • 测评结果:AC
  • 用时:48ms
  • 内存:4108kb
  • [2024-03-19 23:37:41]
  • 提交

answer

#if not LOCAL
#define NDEBUG 1
#endif
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(auto i = a; i < (b); ++i)
#define down(x, a) for (auto x = a; x--;)
#define all(x) begin(x), end(x)
#define sz(x) int(size(x))
#define let auto const

using ll = long long;
using lint = ll;
using pii = pair<int, int>;
using vi = vector<int>;

template <class T> int sgn(T x) { return (x > 0) - (x < 0); }
template<class T>
struct Point {
	typedef Point P;
	T x, y;
	explicit Point(T x=0, T y=0) : x(x), y(y) {}
	bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); }
	bool operator==(P p) const { return tie(x,y)==tie(p.x,p.y); }
	P operator+(P p) const { return P(x+p.x, y+p.y); }
	P operator-(P p) const { return P(x-p.x, y-p.y); }
	P operator*(T d) const { return P(x*d, y*d); }
	P operator/(T d) const { return P(x/d, y/d); }
	T dot(P p) const { return x*p.x + y*p.y; }
	T cross(P p) const { return x*p.y - y*p.x; }
	T cross(P a, P b) const { return (a-*this).cross(b-*this); }
	T dist2() const { return x*x + y*y; }
	double dist() const { return sqrt((double)dist2()); }
	// angle to x-axis in interval [-pi, pi]
	double angle() const { return atan2(y, x); }
	P unit() const { return *this/dist(); } // makes dist()=1
	P perp() const { return P(-y, x); } // rotates +90 degrees
	P normal() const { return perp().unit(); }
	// returns point rotated 'a' radians ccw around the origin
	P rotate(double a) const {
		return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a)); }
	friend ostream& operator<<(ostream& os, P p) {
		return os << "(" << p.x << "," << p.y << ")"; }
};

template<class P> bool onSegment(P s, P e, P p) {
	return p.cross(s, e) == 0 && (s - p).dot(e - p) <= 0;
}

typedef Point<long double> P;
long double segDist(P& s, P& e, P& p) {
	if (s==e) return (p-s).dist();
	auto d = (e-s).dist2(), t = min(d,max((long double).0,(p-s).dot(e-s)));
	return ((p-s)*d-(e-s)*t).dist()/d;
}

template<class P>
bool inPolygon(vector<P> &p, P a, bool strict = true) {
	int cnt = 0, n = sz(p);
	rep(i,0,n) {
		P q = p[(i + 1) % n];
		if (onSegment(p[i], q, a)) return !strict;
		//or: if (segDist(p[i], q, a) <= eps) return !strict;
		cnt ^= ((a.y<p[i].y) - (a.y<q.y)) * a.cross(p[i], q) > 0;
	}
	return cnt;
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int n, m;
  cin>>n>>m;
  vector<vector<pii>> isl(n);
  vector<tuple<int, int, int, int, int, int>> fl(m);
  rep(i, 0, n) {
    int k;
    cin>>k;
    isl[i].resize(k);
    for(auto& [x, y] : isl[i]) cin>>x>>y;
  }
  for(auto& [x1, y1, z1, x2, y2, z2] : fl) {
    cin>>x1>>y1>>z1>>x2>>y2>>z2;
  }

  auto can = [&](long double m) {
    for(auto& is : isl) {
      bool cover = false;
      for(auto& [x1, y1, z1, x2, y2, z2] : fl) {
        if(cover) break;
        bool thiscover = true;
        Point<long double> p1(x1, y1), p2, p3(x2, y2), p4, d;
        d = p3 - p1;
        p2 = p1 - d.normal() * z1 * m;
        p1 = p1 + d.normal() * z1 * m;
        p4 = p3 + d.normal() * z2 * m;
        p3 = p3 - d.normal() * z2 * m;
        vector<Point<long double> > v{p1, p2, p3, p4};
        for(auto [x, y] : is) {
          if(inPolygon(v, Point<long double>(x, y)) == false) {
            thiscover = false;
            break;
          }
        }
        
        if(thiscover) cover = true;
      }
      if(!cover) return false;
    }
    return true;
  };


  long double l = 0, r = 1000000;
  if(!can(r)) {
    cout<<"impossible\n";
    return 0;
  }
  int t = 100;
  while(t--) {
    long double m = (l + r) / 2;
    if(can(m)) r = m;
    else l = m;
  }
  cout<<setprecision(12)<<atan(r) / atan(1) / 4 * 180;
}

詳細信息

Test #1:

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

input:

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

output:

45

result:

ok 

Test #2:

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

input:

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

output:

26.5650511771

result:

ok 

Test #3:

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

input:

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

output:

46.6861433417

result:

ok 

Test #4:

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

input:

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

output:

59.4910411338

result:

ok 

Test #5:

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

input:

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

output:

31.2196984474

result:

ok 

Test #6:

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

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.5288077092

result:

ok 

Test #7:

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

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

result:

ok 

Test #8:

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

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: 3584kb

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: 3544kb

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: 3840kb

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: 3776kb

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: 3756kb

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: 1ms
memory: 3640kb

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: 19ms
memory: 3924kb

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: 23ms
memory: 3868kb

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: 48ms
memory: 3884kb

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.18900164713

result:

ok 

Test #18:

score: 0
Accepted
time: 29ms
memory: 3968kb

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: 35ms
memory: 4108kb

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.57544893598

result:

ok 

Extra Test:

score: 0
Extra Test Passed