QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#87899#5106. Islands from the SkyzokerAC ✓20ms3792kbC++175.6kb2023-03-14 19:43:142023-03-14 19:43:18

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-14 19:43:18]
  • 评测
  • 测评结果:AC
  • 用时:20ms
  • 内存:3792kb
  • [2023-03-14 19:43:14]
  • 提交

answer

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

//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt")

using ll = long long int;
using ull = unsigned long long int;
using vi = vector<ll>;
using ii = pair<ll,ll>;
using vii = vector<ii>;
using ld = long double;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T>
using ordered_set = tree < T, null_type, less<T>,
rb_tree_tag,
tree_order_statistics_node_update >;

#ifdef SA_DEBUG
template <class T>
void print(T a) {cerr << a << endl;}
template <class T, class... V> 
void print(T a, V... b) {cerr << a << ", "; print(b...);}
#define dbg(...) cerr << "[" << __LINE__ << "] " << #__VA_ARGS__ << " :: ", print(__VA_ARGS__)
#else
#define dbg(...) 7
#endif

#define eb emplace_back
#define fi first
#define se second

const ll INFL = 2e18;
const int INF = 1e9;
const double PI = acos(-1);
const ll mod = 1e9+7;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class T, class V> 
ostream& operator << (ostream &s, pair<T, V> a){
	s << a.fi << ' ' << a.se; return s;
}

template<class T, class V> 
istream& operator >> (istream &s, pair<T, V> &a){
	s >> a.fi >> a.se; return s;
}

template<class T> 
ostream& operator << (ostream &s, vector<T> a){
	for(int i = 0; i < (int)a.size(); i++){
		if(i > 0)s << ' ' ; 
		s << a[i];
	} return s;
}

template<class T> 
istream& operator >> (istream &s, vector<T> &a){
	for(T &x : a)s >> x; 
	return s;
}

template<class T> 
void input(T a[], int l, int r, istream &s = cin){
	while(l <= r)s >> a[l++];
}

template<class T> 
void output(T a[], int l, int r, bool en = true, ostream &s = cout){
	while(l <= r){ s << a[l++];
		if(l <= r) s << ' ';
	} if(en)s << "\n";
}



const int N = 4e3+3, K = 26;
//====================================================================//

typedef double Tf; typedef double Ti;
const Tf EPS = 1e-9;
int dcmp(Tf x) {return abs(x)<EPS? 0 :(x<0?-1:1);}
struct PT {
  Ti x, y;
  PT(Ti x = 0, Ti y = 0) : x(x), y(y) {}
  PT operator + (const PT& u) const
            { return PT(x + u.x, y + u.y); }
  PT operator - (const PT& u)
            const { return PT(x - u.x, y - u.y); }
  PT operator * (const long long u)
            const { return PT(x * u, y * u); }
  PT operator * (const Tf u)
            const { return PT(x * u, y * u); }
  PT operator / (const Tf u) const
            { return PT(x / u, y / u); }
  bool operator == (const PT& u) const
       { return dcmp(x-u.x)==0 && dcmp(y-u.y)==0;}
  bool operator != (const PT& u) const
       { return !(*this == u); }
  bool operator < (const PT& u) const
       { return dcmp(x-u.x) < 0 ||
       (dcmp(x-u.x) == 0 && dcmp(y-u.y) < 0);}
  friend istream &operator >> (istream &is, PT &p)
       { return is >> p.x >> p.y; }
  friend ostream &operator << (ostream &os,
         const PT &p) {return os<<p.x<<" "<<p.y; }
};
Ti dot(PT a, PT b) { return a.x*b.x + a.y*b.y; }
Ti cross(PT a, PT b) { return a.x*b.y - a.y*b.x; }

Tf length(PT a) { return sqrt(dot(a, a)); }
struct Segment {
  PT a, b;
  Segment() {}
  Segment(PT aa, PT bb) : a(aa), b(bb) {}
}; typedef Segment Line;
PT rotate90(PT a) { return PT(-a.y, a.x); }
PT scale(PT a, Tf s) {
  static_assert(is_same<Tf, Ti>::value);
  return a / length(a) * s;
}
namespace Linear {
bool onSegment(PT p, Segment s) { ///Is p on S?
  return dcmp(cross(s.a - p, s.b - p)) == 0 &&
         dcmp(dot(s.a - p, s.b - p)) <= 0;
}
}  // namespace Linear
typedef vector<PT> Polygon;
namespace Polygonal {
// returns inside = -1, on = 0, outside = 1
int pointInPolygon(const Polygon &p, PT o) {
  using Linear::onSegment; int wn=0, n = p.size();
  for(int i = 0; i < n; i++) {
    int j = (i + 1) % n; if(onSegment(o,
      Segment(p[i], p[j])) || o == p[i]) return 0;
    int k = dcmp(cross(p[j] - p[i], o - p[i]));
    int d1=dcmp(p[i].y-o.y), d2=dcmp(p[j].y-o.y);
    if(k > 0 && d1 <= 0 && d2 > 0) wn++;
    if(k < 0 && d2 <= 0 && d1 > 0) wn--;
  }
  return wn ? -1 : 1;
}
}
using tup = array<int, 6>;
void testcase(){
	int n, m;
	cin >> n >> m;
	vector<Polygon> pol(n);
	for(auto &X : pol){
		int k;
		cin >> k;
		while(k--){
			int x, y;
			cin >> x >> y;
			X.eb(x, y);
		}
	}
	vector<tup> plane(m);
	for(auto &x : plane){
		for(int j = 0; j < 6; j++)cin >> x[j];
	}
	
	ld lo = 0, hi = PI / 2;
	while(hi - lo > EPS){
		ld mid = (lo + hi) / 2;
		vector<int> taken(n);
		for(auto x : plane){
			ld t1 = x[2] * tan(mid);
			ld t2 = x[5] * tan(mid);
			PT dir = {x[3] - x[0], x[4] - x[1]};
			PT d1 = rotate90(dir);
			PT p1 = {x[0], x[1]};
			PT p2 = {x[3], x[4]};
			Polygon pl;
			pl.eb(p1 + scale(d1, t1));
			pl.eb(p1 - scale(d1, t1));
			pl.eb(p2 - scale(d1, t2));
			pl.eb(p2 + scale(d1, t2));
			//dbg(pl);
			for(int i = 0; i < n; i++){
				if(taken[i])continue;
				bool ok = true;
				for(auto x : pol[i]){
					if(Polygonal::pointInPolygon(pl, x) == 1){
						ok = false;
						break;
					}
				}
				taken[i] = ok;
			}
		}
		//dbg(taken);
		if(accumulate(taken.begin(), taken.end(), 0) == n)hi = mid;
		else lo = mid;
		//dbg(lo, hi, mid);
	}
	if(abs(hi - PI/2) < EPS){
		cout << "impossible\n";
		return;
	}
	cout << fixed << setprecision(10) << hi * 180 / PI << "\n";
}





int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int T = 1;
	//cin >> T;
	
	for(int qq = 1; qq <= T; ++qq){
		//cout << "Case #" << qq << ": ";
		testcase();
	}
	return 0;
}
/*
6 1597352862016328480
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3656kb

input:

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

output:

45.0000000000

result:

ok 

Test #2:

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

input:

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

output:

26.5650512092

result:

ok 

Test #3:

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

input:

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

output:

46.6861433722

result:

ok 

Test #4:

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

input:

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

output:

59.4910411444

result:

ok 

Test #5:

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

input:

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

output:

31.2196984794

result:

ok 

Test #6:

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

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

result:

ok 

Test #7:

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

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: 2ms
memory: 3588kb

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

result:

ok 

Test #9:

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

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: 2ms
memory: 3360kb

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: 2ms
memory: 3560kb

input:

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

output:

63.6657521641

result:

ok 

Test #12:

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

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

result:

ok 

Test #13:

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

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

result:

ok 

Test #14:

score: 0
Accepted
time: 14ms
memory: 3564kb

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: 18ms
memory: 3760kb

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

result:

ok 

Test #16:

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

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

result:

ok 

Test #17:

score: 0
Accepted
time: 19ms
memory: 3768kb

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

result:

ok 

Test #18:

score: 0
Accepted
time: 10ms
memory: 3780kb

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

result:

ok 

Test #19:

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

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

result:

ok 

Extra Test:

score: 0
Extra Test Passed