QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#39667#2935. Spider-FlynidhsWA 4ms3716kbC++3.7kb2022-07-12 18:25:372022-07-12 18:25:39

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-07-12 18:25:39]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3716kb
  • [2022-07-12 18:25:37]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f
#define mod 1000000007
#define pb push_back
typedef pair<int,int> pir;
string sstr[]={"NO\n","YES\n"};
const int N=200010;
int w,h,l;
int w1,h1,l1,w2,h2,l2;
int pos1,pos2;
double cal()
{
	double ans=1e18;
	int d1[4],d2[4];
	int ww,hh,ll;
	if(pos1%3==0){
		d1[0]=w-w1,d2[0]=w-w2;
		d1[1]=h-h1,d2[1]=h-h2;
		d1[2]=w1,d2[2]=w2;
		d1[3]=h1,d2[3]=h2;
		ww=l,hh=h,ll=w;
	}
	else if(pos1%3==1){
		d1[0]=w-w1,d2[0]=w-w2;
		d1[1]=l-l1,d2[1]=l-l2;
		d1[2]=w1,d2[2]=w2;
		d1[3]=l1,d2[3]=l2;
		ww=w,hh=l,ll=h;
	}
	else{
		d1[0]=l-l1,d2[0]=l-l2;
		d1[1]=h-h1,d2[1]=h-h2;
		d1[2]=l1,d2[2]=l2;
		d1[3]=h1,d2[3]=h2;
		ww=h,hh=w,ll=l;
	}
	//不旋转
	for(int i=0;i<4;i++){
		ans=min(ans,sqrt(1.0*(ww+d1[i]+d2[i])*(ww+d1[i]+d2[i])+1.0*abs(d1[(i+1)%4]-d2[(i+1)%4])*abs(d1[(i+1)%4]-d2[(i+1)%4])));
		ans=min(ans,sqrt(1.0*(ww+d1[i]+d2[i])*(ww+d1[i]+d2[i])+1.0*abs(d1[(i-1+4)%4]-d2[(i-1+4)%4])*abs(d1[(i-1+4)%4]-d2[(i-1+4)%4])));
	}
	//旋转一次
	for(int i=0;i<4;i++){
		ans=min(ans,sqrt(1.0*(ww+d1[i]+d2[(i+1)%4])*(ww+d1[i]+d2[(i+1)%4])+1.0*(d2[i]+d1[(i+1)%4])*(d2[i]+d1[(i+1)%4])));
	}
	//旋转2次
	for(int i=0;i<4;i++){
		ans=min(ans,sqrt(1.0*(ww+d1[(i-1+4)%4]+d2[(i+1)%4])*(ww+d1[(i-1+4)%4]+d2[(i+1)%4])+1.0*(ll+d2[i]+d1[i])*(ll+d2[i]+d1[i])));
		ans=min(ans,sqrt(1.0*(ww+d1[(i+1)%4]+d2[(i-1+4)%4])*(ww+d1[(i+1)%4]+d2[(i-1+4)%4])+1.0*(ll+d2[i]+d1[i])*(ll+d2[i]+d1[i])));
	}

	return ans;
}
signed main()
{
	cin>>w>>h>>l;
	cin>>w1>>h1>>l1;
	cin>>w2>>h2>>l2;
	if(w1==0) pos1=4;
	else if(w1==w) pos1=1;
	else if(h1==0) pos1=5;
	else if(h1==h) pos1=2;
	else if(l1==0) pos1=3;
	else if(l1==l) pos1=6;
	else assert(0);
	if(w2==0) pos2=4;
	else if(w2==w) pos2=1;
	else if(h2==0) pos2=5;
	else if(h2==h) pos2=2;
	else if(l2==0) pos2=3;
	else if(l2==l) pos2=6;
	else assert(0);
	if(abs(pos1-pos2)==0){//同面
		printf("%.3lf",sqrt(1.0*(w1-w2)*(w1-w2)+1.0*(h1-h2)*(h1-h2)+1.0*(l1-l2)*(l1-l2)));
	}
	else if(abs(pos1-pos2)==3){//对面
		printf("%.3lf",cal());
	}
	else{//相邻
		double ans=1e18;
		double dis1,dis2;
		if(pos1==1) dis2=w-w2;
		else if(pos1==2) dis2=h-h2;
		else if(pos1==3) dis2=l2;
		else if(pos1==4) dis2=w2;
		else if(pos1==5) dis2=h2;
		else dis2=l-l2;
		if(pos2==1) dis1=w-w1;
		else if(pos2==2) dis1=h-h1;
		else if(pos2==3) dis1=l1;
		else if(pos2==4) dis1=w1;
		else if(pos2==5) dis1=h1;
		else dis1=l-l1;

		//接下来计算经过另外一个面的情形
		int dis11,dis12;
		int dis21,dis22;
		if(pos1%3!=0&&pos2%3!=0){
			ans=min(ans,sqrt(1.0*(dis2+dis2)*(dis1+dis2)+1.0*abs(l1-l2)*abs(l1-l2)));
			//同时往上或者往下
			dis11=l-l1,dis21=l-l2;
			ans=min(ans,sqrt(1.0*(dis21+dis1)*(dis21+dis1)+1.0*(dis11+dis2)*(dis11+dis2)));//经过上面
			dis11=l1,dis21=l2;
			ans=min(ans,sqrt(1.0*(dis21+dis1)*(dis21+dis1)+1.0*(dis11+dis2)*(dis11+dis2)));//经过下面
		}
		else if(pos1%3!=1&&pos2%3!=1){
			ans=min(ans,sqrt(1.0*(dis2+dis2)*(dis1+dis2)+1.0*abs(w1-w2)*abs(w1-w2)));
			dis11=w-w1,dis21=w-w2;
			ans=min(ans,sqrt(1.0*(dis21+dis1)*(dis21+dis1)+1.0*(dis11+dis2)*(dis11+dis2)));//经过上面
			dis11=w1,dis21=w2;
			ans=min(ans,sqrt(1.0*(dis21+dis1)*(dis21+dis1)+1.0*(dis11+dis2)*(dis11+dis2)));//经过下面
		}
		else if(pos1%3!=2&&pos2%3!=2){
			ans=min(ans,sqrt(1.0*(dis2+dis2)*(dis1+dis2)+1.0*abs(h1-h2)*abs(h1-h2)));
			dis11=h-h1,dis21=h-h2;
			ans=min(ans,sqrt(1.0*(dis21+dis1)*(dis21+dis1)+1.0*(dis11+dis2)*(dis11+dis2)));//经过上面
			dis11=h1,dis21=h2;
			ans=min(ans,sqrt(1.0*(dis21+dis1)*(dis21+dis1)+1.0*(dis11+dis2)*(dis11+dis2)));//经过下面
		}
		else assert(0);
		printf("%.3lf",ans);
	}
}

詳細信息

Test #1:

score: 100
Accepted
time: 4ms
memory: 3712kb

input:

12 12 30
6 11 0
6 1 30

output:

40.000

result:

ok single line: '40.000'

Test #2:

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

input:

12 10 30
6 9 0
6 1 30

output:

39.925

result:

wrong answer 1st lines differ - expected: '38.833', found: '39.925'