QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#203067#2483. Roof EscapePlentyOfPenalty#WA 1ms6324kbC++202.1kb2023-10-06 15:10:062023-10-06 15:10:08

Judging History

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

  • [2023-10-06 15:10:08]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:6324kb
  • [2023-10-06 15:10:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e5;
int n,m,sx,sy,ex,ey,vx,vy,g,op;
int nx,ny,mx,my,mm;
double ans;
vector<int>v[N+10];
int Check(int x,int y){
	//cout<<"CHECK "<<x<<" "<<y<<"\n";
	long long t1=1ll*(x-sx)*abs(vy),t2=1ll*abs(y-sy)*vx;
	return t1==t2?0:(t1<t2?1:-1);
}
int main(){
	scanf("%d%d%d%d%d%d",&n,&m,&sx,&sy,&ex,&ey);
	for(int i=1;i<=(n>>1);++i)v[i].resize((m>>1)+1);
	for(int i=1;i<=(m>>1);++i){
		for(int j=1;j<=(n>>1);++j)scanf("%d",&v[j][i]);
	}
	if(sx>ex)swap(sx,ex),swap(sy,ey);
	vx=ex-sx,vy=ey-sy;
	ans=sqrt(1.0*vx*vx+1.0*vy*vy);
	if(vy<0){
		vy=-vy;
		sy=m-sy,ey=m-ey;
		for(int i=1;i<=(n>>1);++i){
			for(int j=1;j<(m>>1)-j+1;++j)swap(v[i][j],v[i][(m>>1)-j+1]);
		}
	}
	if(!vx){
		if(sy>ey)swap(sy,ey);
		for(int i=sy;i<ey;i+=2)ans+=abs(v[sx+1>>1][i+1>>1]-v[sx+1>>1][i+3>>1]);
		printf("%.10lf",ans);
		return 0;
	}
	if(!vy){
		for(int i=sx;i<ex;i+=2)ans+=abs(v[i+1>>1][sy+1>>1]-v[i+3>>1][sy+1>>1]);
		printf("%.10lf",ans);
		return 0;
	}
	//cout<<"ANS="<<ans<<"\n";
	//cout<<"from "<<sx<<" "<<sy<<" to "<<ex<<" "<<ey<<"\n";
	nx=mx=sx-(sx&1);
	ny=sy-(sy&1),my=ny+2;
	op=0;
	while(mx<ex||my<ey){
		//cout<<"("<<nx<<","<<ny<<") ("<<mx<<","<<my<<")\n";
		if(nx==mx){
			if(op)ans+=abs(v[nx>>1][my>>1]-v[nx+2>>1][my>>1]);
			op=Check(nx+2,my);
			if(op>0)nx+=2,mx=nx;
			else if(op<0)mx+=2,(vy<0?my=ny:ny=my);
			else{
				nx+=2,mx=nx;
				if(mx>ex||my>ey)break;
				mm=max(max(v[mx>>1][my>>1],v[mx+2>>1][my+2>>1]),max(v[mx+2>>1][my>>1],v[mx>>1][my+2>>1]));
				ans+=(mm<<1)-v[mx>>1][my>>1]-v[mx+2>>1][my+2>>1];
				ny=my,my+=2;
			}
		}else{
			if(op)ans+=abs(v[mx>>1][ny>>1]-v[mx>>1][ny+2>>1]);
			op=Check(mx,ny+2);
			if(op>0)nx+=2,my+=2;
			else if(op<0)ny+=2,my=ny;
			else{
				ny+=2,my=ny;
				if(mx>ex||my>ey)break;
				mm=max(max(v[mx>>1][my>>1],v[mx+2>>1][my+2>>1]),max(v[mx+2>>1][my>>1],v[mx>>1][my+2>>1]));
				ans+=(mm<<1)-v[mx>>1][my>>1]-v[mx+2>>1][my+2>>1];
				nx=mx,ny=my,my+=2;
			}
		}
		//cout<<"ANS="<<ans<<"\n";
	}
	printf("%.12lf",ans);
	return 0;
}
/*
8 8 1 7 1 1
2 3 2 0
2 1 1 2
1 2 0 0
0 0 0 1
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 26 1 1 3 25
0 1
0 5
5 5
0 1
2 1
4 1
5 0
0 0
1 0
6 4
3 2
5 4
1 5

output:

53.083189157585

result:

ok found '53.08319', expected '53.08319', error '0.00000'

Test #2:

score: 0
Accepted
time: 1ms
memory: 6256kb

input:

8 8 1 7 7 1
2 3 2 0
2 1 1 2
1 2 0 0
0 0 0 1

output:

14.485281374239

result:

ok found '14.48528', expected '14.48528', error '0.00000'

Test #3:

score: 0
Accepted
time: 1ms
memory: 6252kb

input:

2 2 1 1 1 1
100

output:

0.0000000000

result:

ok found '0.00000', expected '0.00000', error '-0.00000'

Test #4:

score: 0
Accepted
time: 1ms
memory: 6192kb

input:

4 4 1 1 3 3
100 1
1 100

output:

2.828427124746

result:

ok found '2.82843', expected '2.82843', error '0.00000'

Test #5:

score: 0
Accepted
time: 0ms
memory: 6276kb

input:

4 4 1 1 3 3
1 100
100 1

output:

200.828427124746

result:

ok found '200.82843', expected '200.82843', error '0.00000'

Test #6:

score: 0
Accepted
time: 1ms
memory: 6264kb

input:

4 4 1 3 3 1
1 100
100 1

output:

2.828427124746

result:

ok found '2.82843', expected '2.82843', error '0.00000'

Test #7:

score: 0
Accepted
time: 1ms
memory: 6256kb

input:

2 56 1 23 1 17
1
0
1
0
1
0
0
4
1
3
1
1
3
0
3
1
1
0
0
2
0
2
1
0
1
0
0
0

output:

10.0000000000

result:

ok found '10.00000', expected '10.00000', error '0.00000'

Test #8:

score: 0
Accepted
time: 1ms
memory: 6316kb

input:

2 28 1 9 1 23
2
1
1
3
2
1
2
0
3
1
1
1
1
3

output:

23.0000000000

result:

ok found '23.00000', expected '23.00000', error '0.00000'

Test #9:

score: 0
Accepted
time: 0ms
memory: 6280kb

input:

2 18 1 11 1 13
1
0
2
0
4
0
2
2
4

output:

4.0000000000

result:

ok found '4.00000', expected '4.00000', error '0.00000'

Test #10:

score: 0
Accepted
time: 1ms
memory: 6324kb

input:

2 400 1 133 1 399
3
6
2
3
0
2
0
3
6
1
6
3
1
5
3
1
6
3
0
2
4
3
3
2
3
0
6
4
2
5
0
3
1
1
3
0
1
3
0
3
5
2
1
2
4
5
0
2
1
0
4
7
3
1
6
4
3
5
2
0
0
3
2
0
2
7
1
0
2
1
2
0
3
0
3
0
6
2
0
4
2
0
3
3
5
0
3
6
3
0
3
2
1
5
1
1
2
6
1
2
1
0
1
2
1
3
2
4
0
5
1
4
2
2
4
4
3
2
1
5
2
3
1
0
0
2
7
5
0
0
2
1
1
0
4
4
2
0
1
4
5
...

output:

560.0000000000

result:

ok found '560.00000', expected '560.00000', error '0.00000'

Test #11:

score: 0
Accepted
time: 1ms
memory: 6324kb

input:

2 200 1 117 1 97
1
7
2
2
0
4
3
0
0
0
0
5
4
0
4
4
7
0
2
7
3
5
0
1
2
4
2
0
0
0
3
3
1
3
2
2
2
0
3
3
3
0
0
3
1
3
4
2
1
6
0
1
0
2
1
3
5
2
5
2
0
1
0
1
0
1
1
3
3
3
1
5
1
1
7
0
2
2
2
7
2
1
4
3
1
1
0
0
1
2
1
0
6
2
2
2
1
1
1
0

output:

46.0000000000

result:

ok found '46.00000', expected '46.00000', error '0.00000'

Test #12:

score: 0
Accepted
time: 1ms
memory: 6324kb

input:

2 132 1 41 1 65
3
0
3
3
2
2
5
2
0
2
3
3
2
1
2
4
0
4
5
1
2
1
0
2
2
1
0
6
1
1
5
2
1
0
2
4
2
5
1
6
0
3
1
1
5
1
2
7
2
2
2
1
5
6
0
5
4
0
5
2
1
1
1
4
0
0

output:

49.0000000000

result:

ok found '49.00000', expected '49.00000', error '0.00000'

Test #13:

score: 0
Accepted
time: 1ms
memory: 6312kb

input:

4 100 3 37 3 53
2 0
1 3
0 4
2 0
0 2
0 1
0 4
4 0
5 5
3 6
1 4
1 1
6 0
1 3
3 5
5 4
3 0
2 0
2 3
0 1
0 3
4 4
5 3
3 0
0 2
4 1
0 3
0 5
1 2
1 4
1 0
2 0
2 0
0 0
0 2
4 1
4 0
1 5
4 0
0 2
1 7
6 2
1 4
0 0
0 6
5 5
2 0
0 3
3 1
2 4

output:

30.0000000000

result:

ok found '30.00000', expected '30.00000', error '0.00000'

Test #14:

score: 0
Accepted
time: 0ms
memory: 6312kb

input:

4 80 1 67 3 57
1 4
0 5
1 3
1 6
0 0
5 0
0 1
1 0
0 6
3 0
4 0
1 0
1 2
1 2
0 0
6 2
2 2
1 3
0 3
3 2
2 2
0 3
1 2
0 2
0 0
6 6
1 4
1 4
0 4
1 7
1 3
6 1
3 3
5 5
1 1
4 3
1 4
3 5
5 1
2 1

output:

25.198039027186

result:

ok found '25.19804', expected '25.19804', error '0.00000'

Test #15:

score: 0
Accepted
time: 1ms
memory: 6260kb

input:

6 66 1 59 1 51
2 1 1
5 2 6
2 3 2
0 2 6
2 3 2
0 4 2
4 1 5
2 0 6
4 2 2
0 0 1
1 2 0
3 4 2
0 2 1
1 1 2
4 0 3
0 1 0
2 6 5
1 0 5
0 2 1
1 3 3
2 5 3
3 1 4
1 7 1
3 2 5
2 0 5
3 4 5
4 3 0
5 2 4
0 6 3
2 4 4
1 2 0
0 6 0
4 4 3

output:

17.0000000000

result:

ok found '17.00000', expected '17.00000', error '0.00000'

Test #16:

score: 0
Accepted
time: 0ms
memory: 6320kb

input:

6 56 1 19 5 19
1 5 5
1 1 4
4 2 4
0 0 2
0 1 4
4 2 3
3 1 5
4 4 2
4 4 3
3 0 2
0 1 1
7 2 5
0 3 1
4 1 2
6 0 5
3 1 2
0 6 3
5 2 1
1 2 4
0 1 0
0 0 3
5 1 2
5 2 0
4 5 1
6 5 2
3 2 4
5 6 4
5 7 0

output:

9.0000000000

result:

ok found '9.00000', expected '9.00000', error '0.00000'

Test #17:

score: 0
Accepted
time: 0ms
memory: 6320kb

input:

8 50 1 31 3 7
4 3 3 1
1 3 0 1
6 0 1 4
0 0 1 5
1 3 0 3
0 4 0 0
3 3 3 5
2 3 2 1
0 5 1 4
1 5 3 7
1 2 4 3
6 0 3 1
2 5 6 0
4 5 4 2
2 1 1 7
6 2 4 3
2 3 3 0
0 0 2 3
2 0 4 1
0 1 3 3
2 0 2 5
2 6 1 0
3 1 2 1
5 2 4 1
0 2 4 2

output:

52.083189157585

result:

ok found '52.08319', expected '52.08319', error '0.00000'

Test #18:

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

input:

8 44 3 13 7 17
1 4 1 5
2 1 0 4
1 0 5 2
0 0 4 0
1 0 4 2
5 2 2 0
0 1 1 1
1 0 2 4
1 0 3 3
4 0 1 0
0 2 2 4
4 1 1 0
4 7 2 2
4 4 4 5
0 2 0 2
4 2 6 2
4 1 3 0
4 6 2 4
7 3 2 0
6 4 1 0
1 2 5 1
2 2 3 0

output:

9.656854249492

result:

wrong answer 1st numbers differ - expected: '7.65685', found: '9.65685', error = '0.26120'