QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#292366#6302. MapzzuqyWA 1ms3944kbC++144.4kb2023-12-28 02:35:492023-12-28 02:35:49

Judging History

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

  • [2023-12-28 02:35:49]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3944kb
  • [2023-12-28 02:35:49]
  • 提交

answer

//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <ctime>
#include <cctype>
#include <queue>
#include <deque>
#include <stack>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <utility>
#include <bitset>
#include <set>
#include <map>
#define ll long long
#define db double
#define INF 5000000000000000ll
#define inf 1000000000
#define EPS 1e-10
#define ldb long double
#define pb push_back
#define put_(x) printf("%d ",x);
#define get(x) x=read()
#define putl(x) printf("%lld\n",x)
#define rep(p,n,i) for(int i=p;i<=n;++i)
#define go(x) for(int i=lin[x],tn=ver[i];i;tn=ver[i=nex[i]])
#define pii pair<int,int>
#define mk make_pair
#define P 1000000007ll
#define gf(x) scanf("%lf",&x)
#define pf(x) ((x)*(x))
#define uint unsigned long long
#define ui unsigned
#define sq sqrt
#define l(w) t[w].l
#define r(w) t[w].r
#define m(w) t[w].m
#define mn(w) t[w].mn
#define c(w) t[w].c
#define s(w) t[w].s
#define tag(w) t[w].tag
#define S second
#define F first
#define mod 1000000007
#define sc(A) scanf("%d",&A)
#define scs(A) scanf("%s",A);
#define put(A) printf("%d\n",A)
#define fep(p,n,cc) for(int cc=p;cc>=n;--cc)
#define scl(A) scanf("%lld",&A)
using namespace std;
const int MAXN = 2010;
int T;
int n,k;
pair<db,db> a[MAXN],b[MAXN],d[MAXN];
pair<db,db> A[MAXN],B[MAXN];
pair<db,db> w1[MAXN],w2[MAXN];
int s1,s2,s3,s4;
int main()
{
	//freopen("1.in","r",stdin);
	sc(T);
	while(T--)
	{
		db ans=2000000000;
		
		sc(s1);sc(s2);
		a[1].F=s1;a[1].S=s2;
		sc(s1);sc(s2);
		b[1].F=s1;b[1].S=s2;
		sc(s1);sc(s2);
		//c[1].F=s1;c[1].S=s2;
		sc(s1);sc(s2);
		d[1].F=s1;d[1].S=s2;
		A[1]=mk(b[1].F-a[1].F,b[1].S-a[1].S);
		B[1]=mk(d[1].F-a[1].F,d[1].S-a[1].S);
		
		sc(s1);sc(s2);
		a[2].F=s1;a[2].S=s2;
		sc(s1);sc(s2);
		b[2].F=s1;b[2].S=s2;
		sc(s1);sc(s2);
		//c[1].F=s1;c[1].S=s2;
		sc(s1);sc(s2);
		d[2].F=s1;d[2].S=s2;
		A[2]=mk(b[2].F-a[2].F,b[2].S-a[2].S);
		B[2]=mk(d[2].F-a[2].F,d[2].S-a[2].S);
		
		sc(s1);
		sc(s2);
		sc(s3);
		sc(s4);
		w1[1].F=s1;w1[1].S=s2;
		w2[1].F=s3;w2[1].S=s4;
		sc(k);sc(n);
		rep(3,n+1,i)
		{
			//求a的(x,y)坐标
			//(x,y)=(x',y')A^{-1}
			db det=A[i-2].F*B[i-2].S-A[i-2].S*B[i-2].F;
			det=1/det;
			db xx=a[i-1].F-a[i-2].F;
			db yy=a[i-1].S-a[i-2].S;
			db x=B[i-2].S*xx-B[i-2].F*yy;
			db y=-A[i-2].S*xx+A[i-2].F*yy;
			x=x*det;
			y=y*det;
			//cout<<x<<' '<<y<<endl;
			xx=x*A[i-1].F+y*B[i-1].F;
			yy=x*A[i-1].S+y*B[i-1].S;
			//cout<<xx<<' '<<yy<<endl;
			a[i].F=xx+a[i-1].F;
			a[i].S=yy+a[i-1].S;
			
			xx=b[i-1].F-a[i-2].F;
			yy=b[i-1].S-a[i-2].S;
			x=B[i-2].S*xx-B[i-2].F*yy;
			y=-A[i-2].S*xx+A[i-2].F*yy;
			x=x*det;
			y=y*det;
			//cout<<x<<' '<<y<<endl;
			xx=x*A[i-1].F+y*B[i-1].F;
			yy=x*A[i-1].S+y*B[i-1].S;
			//cout<<xx<<' '<<yy<<endl;
			b[i].F=xx+a[i-1].F;
			b[i].S=yy+a[i-1].S;

			xx=d[i-1].F-a[i-2].F;
			yy=d[i-1].S-a[i-2].S;
			x=B[i-2].S*xx-B[i-2].F*yy;
			y=-A[i-2].S*xx+A[i-2].F*yy;
			x=x*det;
			y=y*det;
			//cout<<x<<' '<<y<<endl;
			xx=x*A[i-1].F+y*B[i-1].F;
			yy=x*A[i-1].S+y*B[i-1].S;
			//cout<<xx<<' '<<yy<<endl;
			d[i].F=xx+a[i-1].F;
			d[i].S=yy+a[i-1].S;

			//cout<<d[i].F<<' '<<d[i].S<<endl;

			A[i]=mk(b[i].F-a[i].F,b[i].S-a[i].S);
			B[i]=mk(d[i].F-a[i].F,d[i].S-a[i].S);
		}

		db det=A[1].F*B[1].S-A[1].S*B[1].F;
		det=1/det;
		db xx=w1[1].F-a[1].F;
		db yy=w1[1].S-a[1].S;
		db x=B[1].S*xx-B[1].F*yy;
		db y=-A[1].S*xx+A[1].F*yy;
		x=x*det;
		y=y*det;
		rep(2,n+1,i)
		{
			w1[i].F=x*A[i].F+y*B[i].F+a[i].F;
			w1[i].S=x*A[i].S+y*B[i].S+a[i].S;
			//cout<<w1[i].F<<' '<<w1[i].S<<endl;
		}

		det=A[1].F*B[1].S-A[1].S*B[1].F;
		det=1/det;
		xx=w2[1].F-a[1].F;
		yy=w2[1].S-a[1].S;
		x=B[1].S*xx-B[1].F*yy;
		y=-A[1].S*xx+A[1].F*yy;
		x=x*det;
		y=y*det;
		rep(2,n+1,i)
		{
			w2[i].F=x*A[i].F+y*B[i].F+a[i].F;
			w2[i].S=x*A[i].S+y*B[i].S+a[i].S;
			//cout<<w2[i].F<<' '<<w2[i].S<<endl;
		}
		rep(0,n,i)rep(0,n-i,j)
		{
			x=w1[i+1].F-w2[j+1].F;
			y=w1[i+1].S-w2[j+1].S;
			x=x*x+y*y;
			x=sqrt(x);
			//cout<<i<<' '<<j<<' '<<x<<' '<<w1[i+1].F<<' '<<w2[j+1].F<<' '<<w1[i+1].S<<' '<<w2[j+1].S<<endl;
			ans=min(ans,k*(i+j)+x);
		}
		//printf("%.10lf\n",ans);
		printf("%.10lf\n",fabs(ans)<=EPS?0:ans);
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
0 0 0 2 4 2 4 0
0 0 0 1 2 1 2 0
2 1 4 2
1 1
0 0 0 3 6 3 6 0
0 1 1 0 3 2 2 3
0 0 4 2
0 3

output:

1.0000000000
1.2272623352

result:

ok 2 numbers

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3856kb

input:

100
-133 -128 -109 -134 -85 -38 -109 -32
-95 -37 -100 -35 -108 -55 -103 -57
-119 -130 -112 -44
2 73
5 -100 5 -8 1 -8 1 -100
1 -60 1 -14 3 -14 3 -60
3 -84 1 -20
2 53
-58 -78 -66 -78 -66 -34 -58 -34
-58 -34 -66 -34 -66 -78 -58 -78
-63 -50 -63 -37
4 54
52 -148 116 -148 116 -52 52 -52
53 -103 53 -71 101...

output:

0.0000000000
12.2297310789
13.0000000000
0.0000000000
13.3416640641
0.0000000000
0.0000000000
0.0000000000
21.2800377341
59.7760220926
4.1231056256
79.6492310070
65.0691939400
14.1421356237
41.8246155035
0.0000000000
0.0000000000
21.5622023742
0.0000000000
21.0237960416
20.8806130178
24.3310501212
4...

result:

wrong answer 1st numbers differ - expected: '9.5006575', found: '0.0000000', error = '1.0000000'