QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#556695#8081. Minimum Manhattan DistanceJinTianHaoWA 57ms4000kbC++171.4kb2024-09-10 20:14:592024-09-10 20:14:59

Judging History

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

  • [2024-09-10 20:14:59]
  • 评测
  • 测评结果:WA
  • 用时:57ms
  • 内存:4000kb
  • [2024-09-10 20:14:59]
  • 提交

answer

#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
// #define int long long
// #pragma GCC optimize("Ofast","inline","-ffast-math")
// #pragma GCC target("avx,sse2,sse3,sse4,mmx")
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
const double eps=1e-8;
double solve(double x,double y,double xx,double yy)
{
	return fabs(x-xx)+fabs(y-yy);
}
signed main()
{
	// freopen(".in","r",stdin);
	// freopen(".out","w",stdout);
	int tc;read(tc);
	while(tc--)
	{
		int x11,y11,x12,y12;
		int x21,y21,x22,y22;
		read(x11);read(y11);read(x12);read(y12);
		read(x21);read(y21);read(x22);read(y22);
		double xc=(x21+x22)/2.0,yc=(y21+y22)/2.0;
		double r=sqrtl((x21-x22)*(x21-x22)+(y21-y22)*(y21-y22))/2.0;
		double ans=min({
			solve(xc+r*sqrt(2)/2,yc+r*sqrt(2)/2,(x11+x12)/2.0,(y11+y12)/2.0),
			solve(xc-r*sqrt(2)/2,yc+r*sqrt(2)/2,(x11+x12)/2.0,(y11+y12)/2.0),
			solve(xc+r*sqrt(2)/2,yc-r*sqrt(2)/2,(x11+x12)/2.0,(y11+y12)/2.0),
			solve(xc-r*sqrt(2)/2,yc-r*sqrt(2)/2,(x11+x12)/2.0,(y11+y12)/2.0)
		});
		printf("%.10lf\n",ans);
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
0 0 2 1
4 5 5 2

output:

4.2639320225

result:

ok Your answer is acceptable!^ ^

Test #2:

score: -100
Wrong Answer
time: 57ms
memory: 4000kb

input:

100000
64184 -33682 59295 3067
16568 83379 -30901 17899
4747 16156 33365 80028
-41011 -93961 -89583 -95743
96914 -33206 12828 -88885
-93518 29681 -82022 42270
40225 76998 25677 84480
66361 -32945 94822 -81258
-17979 41800 -91442 80586
40229 -78184 30070 -89624
-21082 -94587 48262 -87979
-95197 91518...

output:

nan
nan
227607.1060353066
nan
224138.5231894689
nan
nan
nan
199492.5989142839
nan
110927.1824394682
154352.4008228031
130471.0514280389
193239.8699309033
nan
263673.1346103439
128129.5646587627
83809.4379227885
232037.1188173308
nan
103257.9981040720
180822.5765704457
176577.7755165118
nan
nan
16231...

result:

wrong output format Expected double, but "nan" found