QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#398847#2338. Beautiful BridgesBIXIANWA 1ms4236kbC++141.4kb2024-04-25 19:03:562024-04-25 19:03:56

Judging History

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

  • [2024-04-25 19:03:56]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4236kb
  • [2024-04-25 19:03:56]
  • 提交

answer

#include<iostream>
#include<algorithm>
using namespace std;
int f[100001];
long long n, h, a, d,ans;
long long s[100001][2];
long long qw[10002],qe[10002];
bool df(int a, int b)
{
	long long midy = (h>>1) -(b - a);
	if (midy < (f[a]>>1) || midy < (f[b]>>1))
		return 0;
	long long midx = (a + b);
	long long r = (b -a);
	r *= r;
	for (int i = a; i <= b; i++)
	{
		if (f[i]>=0)
		{
			if (((f[i]>>1)>=midy)&&((midx - (i>>1)) * (midx - (i>>1)) + (midy - (f[i]>>1)) * (midy -(f[i]>>1)))>r)
				return 0;
		}
	}
	return 1;
}
int vv = 0;
long long min1 = -1;
void dfs()
{
	for (int i = 2; i <= ans; i++)
	{
		for (int u = i-1; u>=1; u--)
		{
			if (qw[u]&&(df(s[u][0], s[i][0])))
			{
				if (!qw[i])
				{
					qw[i] = qw[u] + d * ((s[i][0] - s[u][0]) * (s[i][0] - s[u][0])) + s[i][1];
					
				}
				else
				{
					qw[i] = min(qw[i], qw[u] + d * ((s[i][0] - s[u][0]) * (s[i][0] - s[u][0])) + s[i][1]);
					
				}
				if (i == ans)
				{
					if (min1 > qw[i]||min1==-1)
						min1 = qw[i];
					vv = 1;
				}
			}
		}
	}
}
int main()
{
	cin >> n >> h >> a >> d;
	int x,fr;
	ans = n;
	for (int i = 1; i <= 100000; i++)
		f[i] = -1;
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &x);
		scanf("%d", &f[x]);
		s[i][0] = x;
		s[i][1] = a * (h - f[s[i][0]]);
	}
	qw[1] = s[1][1];
	
	dfs();
	if (!vv)
		cout << "impossible";
	if(vv)
		cout << min1 << endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 4236kb

input:

5 60 18 2
0 0
20 20
30 10
50 30
70 20

output:

impossible

result:

wrong answer 1st lines differ - expected: '6460', found: 'impossible'