QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#39698#2935. Spider-FlynidhsWA 2ms3748kbC++3.9kb2022-07-12 20:33:392022-07-12 20:33: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 20:33:39]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3748kb
  • [2022-07-12 20:33:39]
  • 提交

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 cal3()
{
	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=w,ll=h;
	}
	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;
}
double cal2()
{
	double ans=1e18;
	int d1[4],d2[4];
	int ww,hh,ll;
	if(pos1==1) d2[0]=w-w2,d2[2]=w2;
	else if(pos1==2) d2[0]=h-h2,d2[2]=h2;
	else if(pos1==3) d2[0]=l2,d2[2]=l-l2;
	else if(pos1==4) d2[0]=w2,d2[2]=w-w2;
	else if(pos1==5) d2[0]=h2,d2[2]=h-h2;
	else d2[0]=l-l2,d2[2]=l2;

	if(pos2==1) d1[0]=w-w1,d1[2]=w1;
	else if(pos2==2) d1[0]=h-h1,d1[2]=h1;
	else if(pos2==3) d1[0]=l1,d1[2]=l-l1;
	else if(pos2==4) d1[0]=w1,d1[2]=w-w1;
	else if(pos2==5) d1[0]=h1,d1[2]=h-h1;
	else d1[0]=l-l1,d1[2]=l1;
	if(pos1%3!=0&&pos2%3!=0){
		d1[1]=l-l1;
		d1[3]=l1;
		d2[1]=l-l2;
		d2[3]=l2;
		hh=l;
		if(pos1%3==1) ll=h,ww=w;
		else ll=w,ww=h; 
	}
	else if(pos1%3!=1&&pos1%3!=1){
		d1[1]=w-w1;
		d1[3]=w1;
		d2[1]=w-w2;
		d2[3]=w2;
		hh=w;
		if(pos1%3==0) ll=h,ww=l;
		else ll=l,ww=h; 
	}
	else{
		d1[1]=h-h1;
		d1[3]=h1;
		d2[1]=h-h2;
		d2[3]=h2;
		hh=h;
		if(pos1%3==0) ll=w,ww=l;
		else ll=l,ww=w; 
	}
	// cout<<d1[0]<<' '<<d1[1]<<' '<<d1[2]<<' '<<d1[3]<<' '<<ll<<'\n';
	// cout<<d2[0]<<' '<<d2[1]<<' '<<d2[2]<<' '<<d2[3]<<' '<<ww<<'\n';
	//不转
	ans=min(ans,sqrt(1.0*(d1[0]+d2[0])*(d1[0]+d2[0])+1.0*abs(d1[1]-d2[1])*abs(d1[1]-d2[1])));
	//转一圈
	ans=min(ans,sqrt(1.0*(d1[0]+d2[1])*(d1[0]+d2[1])+1.0*(d1[1]+d2[0])*(d1[1]+d2[0])));
	ans=min(ans,sqrt(1.0*(d1[0]+d2[3])*(d1[0]+d2[3])+1.0*(d1[3]+d2[0])*(d1[3]+d2[0])));
	//转2圈
	ans=min(ans,sqrt(1.0*(d1[2]+d2[0])*(d1[2]+d2[0])+1.0*(d1[1]+d2[1]+ll)*(d1[1]+d2[1]+ll)));
	ans=min(ans,sqrt(1.0*(d1[2]+d2[0])*(d1[2]+d2[0])+1.0*(d1[3]+d2[3]+ll)*(d1[3]+d2[3]+ll)));
	ans=min(ans,sqrt(1.0*(d2[2]+d1[0])*(d2[2]+d1[0])+1.0*(d2[1]+d1[1]+ww)*(d2[1]+d1[1]+ww)));
	ans=min(ans,sqrt(1.0*(d2[2]+d1[0])*(d2[2]+d1[0])+1.0*(d2[3]+d1[3]+ww)*(d2[3]+d1[3]+ww)));
	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",cal3());
	}
	else{//相邻
		printf("%.3lf",cal2());
		
	}
}
/*
12 10 30
1 10 10
6 1 30
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3696kb

input:

12 12 30
6 11 0
6 1 30

output:

40.000

result:

ok single line: '40.000'

Test #2:

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

input:

12 10 30
6 9 0
6 1 30

output:

38.833

result:

ok single line: '38.833'

Test #3:

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

input:

12 10 30
1 10 10
6 1 30

output:

27.019

result:

ok single line: '27.019'

Test #4:

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

input:

12 10 30
1 10 10
6 2 30

output:

27.514

result:

ok single line: '27.514'

Test #5:

score: -100
Wrong Answer
time: 2ms
memory: 3700kb

input:

12 10 30
1 10 10
8 0 30

output:

28.284

result:

wrong answer 1st lines differ - expected: '27.586', found: '28.284'