QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#768204#9455. Getting LostUnratedLegendaryGrandMasters (Emanuel Enrique Soto Ortega, Mijail Frank Poccohuanca Copac, Joel Jhotan Chavez Chico)#WA 1ms3980kbC++203.4kb2024-11-21 02:27:052024-11-21 02:27:06

Judging History

This is the latest submission verdict.

  • [2024-11-21 02:27:06]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3980kb
  • [2024-11-21 02:27:05]
  • Submitted

answer

#include<bits/stdc++.h>
#define point complex<double>
#define x real()
#define y imag()
#define pb push_back
using namespace std;
using db = double;

const db inf = 1e14;
db cross(point a,point b){return imag(conj(a)*b);}
db dot(point a,point b){return real(conj(a)*b);}

point rot90(point p){
	return point(-p.y,p.x);
}
struct circle{
	point p;
	db r;
	circle(){}
	circle(point _p,db _r):p(_p),r(_r){}
	db dist(point a,point b){
		point u=b-a;
		u/=abs(b-a);
		db dt=dot(u,p-a);
		if(dt<0 || dt>abs(b-a)) return min(abs(p-a),abs(p-b));
		return abs(cross(u,p-a));
	}
	bool inter(point a,point b){
		return dist(a,b)<r;
	}
	pair<point,point> tang(point a){
		db d=abs(a-p);
		db h=r*sqrt(d*d-r*r)/d;
		point u = p - a;
		u/=d;
		d -= r*r/d;
		point v (-u.y,u.x);
		u*=d;
		a+=u;
		v*=h;
		return {a-v,a+v};
	}
	friend void ctang(circle c1,circle c2,vector<point> &t1,vector<point> &t2){
		
		if(c1.r>c2.r) swap(c1,c2),swap(t1,t2);
		circle c(c2.p, c2.r - c1.r);
		auto [p1,p2] = c.tang(c1.p);
		point u = p1 - c1.p;
		u /= abs(p1 - c1.p);
		u = rot90(u);
		u *= c1.r;
		t1.pb(c1.p + u);
		t2.pb(p1 + u);
		u = p2 - c1.p;
		u /= abs(p2 - c1.p);
		u = rot90(u);
		u *= c1.r;
		t1.pb(c1.p - u);
		t2.pb(p2 - u);
		c = circle(c2.p, c1.r + c2.r);
		auto [p3,p4] = c.tang(c1.p);
		u = p3 - c1.p;
		u /= abs(p3 - c1.p);
		u = rot90(u);
		u *= c1.r;
		t1.pb(c1.p - u);
		t2.pb(p3 - u);
		u = p4 - c1.p;
		u /= abs(p4 - c1.p);
		u = rot90(u);
		u *= c1.r;
		t1.pb(c1.p + u);
		t2.pb(p4 + u);
	}
};
point readp(){
	int u,v;
	cin>>u>>v;
	return point(u,v);
}
int main(){
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		int R;
		point st=readp(),ed=readp();
		cin>>R;
		vector<circle> c(n);
		for(int i=0;i<n;i++){
			point p=readp();
			int r;
			cin>>r;
			c[i]=circle(p,r);
		}
		vector<vector<point>> p(n);
		if(n==2){
			ctang(c[0], c[1], p[0], p[1]);
		}
		int sz=2;
		for(int i=0;i<n;i++){
			auto [p1,p2] = c[i].tang(st);
			p[i].pb(p1);
			p[i].pb(p2);
			auto [p3,p4] = c[i].tang(ed);
			p[i].pb(p3);
			p[i].pb(p4);
			sz+=p[i].size();
		}
		vector<vector<db>> w(sz,vector<db>(sz,inf));
		auto check=[&](point a,point b){
			for(int i=0;i<n;i++){
				if(c[i].inter(a,b)) return false;
			}
			return true;
		};
		if(check(st,ed)) w[0][1] = w[1][0] = max(abs(ed-st)-R, 0.0);
		
		if(n==2){
			for(int i=0;i<p[0].size();i++){
				int curr = p[0].size();
				for(int j=0;j<p[1].size();j++){
					if(check(p[0][i],p[1][j])) w[2 + i][2 + curr + j] = w[2 + curr + j][2 + i] = abs(p[0][i] - p[1][j]);
				}
			}
		}
		int cum = 2;
		for(int i=0;i<n;i++){
			for(int j=0;j<p[i].size();j++){
				if(check(st,p[i][j])) w[0][cum + j] = w[cum + j][0] = abs(st - p[i][j]);
				if(check(ed,p[i][j])) w[1][cum + j] = w[cum + j][1] = max(abs(ed - p[i][j]) - R, 0.0);
			}
			for(int j=0;j<p[i].size();j++){
				for(int k=0;k<p[i].size();k++){
					point a = p[i][j] - c[i].p;
					point b = p[i][k] - c[i].p;
					db angle = acosl(dot(a,b)/c[i].r/c[i].r);
					w[cum + j][cum + k] = w[cum + k][cum + j] = angle * c[i].r;
				}
			}
			cum += p[i].size();
		}
		vector<db> d(sz,inf);
		vector<bool> vis(sz,false);

		d[0]=0;

		while(true){
			double best=inf;
			int now=-1;
			for(int j=0;j<sz;j++){
				if(!vis[j] && d[j]<best){
					best=d[j];
					now=j;
				}
			}
			if(now==-1) break;
			vis[now]=true;
			for(int next=0;next<sz;next++){
				if(!vis[next] && d[next] > d[now] + w[now][next]){
					d[next] = d[now] + w[now][next];
				}
			}
			
		}
		cout<<setprecision(12)<<fixed;
		cout<<d[1]<<"\n";
		
	}
	return 0;
}

詳細信息

Test #1:

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

input:

2
1
10 0
0 0 2
6 0 1
0
0 10
0 0 5

output:

8.209191463669
5.000000000000

result:

ok 2 numbers

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3860kb

input:

52
0
0 10
0 0 5
0
10 0
0 0 5
1
10 0
0 0 2
6 0 1
1
10 0
4 0 2
6 0 1
1
10 0
3 0 4
6 0 2
1
10 0
3 0 2
6 0 3
1
10 0
3 0 4
6 0 3
2
10 0
-2 0 4
6 4 3
6 -4 3
2
10 0
-2 0 7
6 4 3
6 -4 3
2
10 6
-2 0 7
6 4 3
6 -4 3
2
10 2
-2 0 14
6 4 3
6 -4 3
2
14 4
-2 0 14
6 4 3
6 -4 3
2
12 -10
-2 0 14
2 2 3
6 -4 3
2
8 -8
-2...

output:

5.000000000000
5.000000000000
8.209191463669
100000000000000.000000000000
100000000000000.000000000000
9.902326528394
9.902326528394
8.000000000000
5.000000000000
7.974839769675
3.636838397359
4.985601854001
9.082225489417
4.618186670119
6.708134115479
3.812149652279
2.000000000000
40.900063390609
5...

result:

wrong answer 4th numbers differ - expected: '4.3936128', found: '100000000000000.0000000', error = '22760312456653.1406250'