QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#203359#2483. Roof EscapePhantomThreshold#WA 0ms3972kbC++202.4kb2023-10-06 16:54:082023-10-06 16:54:08

Judging History

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

  • [2023-10-06 16:54:08]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3972kb
  • [2023-10-06 16:54:08]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define int long long
using namespace std;

int n,m,N;
int sx,sy,tx,ty;
vector< vector<int> >h;

int sqr(int x){ return x*x; }

double ans;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>m>>n>>sy>>sx>>ty>>tx;
	
	ans= hypot( sx-tx,sy-ty );
	
	for(int i=1;i<=n/2;i++)
	{
		vector<int>_;
		for(int j=1;j<=m/2;j++) 
		{
			int hi; cin>>hi;
			_.push_back(hi);
			_.push_back(hi);
		}
		h.push_back(_);
		h.push_back(_);
	}
	
	if(sx>tx)
	{
		for(int i=0;i<n;i++) if(i<n-i-1)
		{
			swap(h[i],h[n-i-1]);
		}
		swap(sx,tx);
	}
	if(sy>ty)
	{
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++) if(j<m-j-1)
			{
				swap(h[i][j],h[i][m-j-1]);
			}
		}
		swap(sy,ty);
	}
	
	int dx=tx-sx, dy=ty-sy;
	{
		int d= __gcd(abs(dx),abs(dy));
		dx/=d, dy/=d;
	}
	
	if(sx==tx)
	{
		if(sy<ty)
		{
			for(int j=sy;j<ty;j++) ans+=abs(h[sx][j]-h[sx][j+1]);
		}
/*		else
		{
			for(int j=sy;j>ty;j--) ans+=abs(h[sx][j]-h[sx][j-1]);
		}*/
	}
	else
	{
		for(int i=sx+1,j=sy;i<=tx;i++)
		{
			double d, u;
			if(sy<=ty)
			{
				d= (double)sy+(i-1-sx)*dy/dx;
				u= (double)sy+(i-sx)*dy/dx;
				
				int pj=j;
				while( (j+1)<=u )
				{
					if(j+1==u && (i-sx)*dy%dx==0)
					{
						if( min(h[i-1][j+1],h[i][j]) > max(h[i-1][j],h[i][j+1]) )
						{
							int temp= min(h[i-1][j+1],h[i][j]);
							ans+= abs( temp-h[i-1][j] ) + abs( temp-h[i][j+1] );
							j++;
						}
						else
						{
							ans+= abs(h[i-1][j]-h[i][j+1]);
							j++;
						}
					}
					else
					{
						ans+= abs(h[i-1][j]-h[i-1][j+1]);
						j++;
					}
				}
				if( (i-sx)*abs(dy)%dx!=0 || j==pj )
				{
					ans+= abs( h[i-1][j]-h[i][j] );
				}
			}
		/*	else
			{
				u= (double)sy+(i-1-sx)*dy/dx;
				d= (double)sy+(i-sx)*dy/dx;
				
				while( (j-1)>=d )
				{
					if(j-1==d && (i-sx)*abs(dy)%dx==0)
					{
						if( min(h[i-1][j-1],h[i][j]) > max(h[i-1][j],h[i][j-1]) )
						{
							int temp= min(h[i-1][j-1],h[i][j]);
							ans+= abs( temp-h[i-1][j] ) + abs( temp-h[i][j-1] );
							j--;
						}
						else
						{
							ans+= abs(h[i-1][j]-h[i][j-1]);
						}
					}
					else
					{
						ans+= abs(h[i-1][j]-h[i-1][j-1]);
						j--;
					}
				}
				if( (i-sx)*abs(dy)%dx!=0 )
				{
					ans+= abs( h[i-1][j]-h[i][j] );
				}
			}*/
		}
	}
	cout<<fixed<<setprecision(12)<<ans<<endl;
	
	return 0;
}

详细

Test #1:

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

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: 0ms
memory: 3972kb

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: 0ms
memory: 3964kb

input:

2 2 1 1 1 1
100

output:

0.000000000000

result:

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

Test #4:

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

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: 3848kb

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: 0ms
memory: 3876kb

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: -100
Wrong Answer
time: 0ms
memory: 3968kb

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:

9.000000000000

result:

wrong answer 1st numbers differ - expected: '10.00000', found: '9.00000', error = '0.10000'