QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#507491#2338. Beautiful BridgesflyingCompile Error//C++14842b2024-08-06 18:19:202024-08-06 18:19:21

Judging History

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

  • [2024-08-06 18:19:21]
  • 评测
  • [2024-08-06 18:19:20]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define int long long

const int N=1e4+5;

int dp[N], x[N], y[N], n, h;
bool can[N][N];

int dist(int x1,int y1,int x2,int y2)
{
	return (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);
}

bool check(int l,int r)
{
	int lim=2*h-(x[r]-x[l]);
	for(int i=l;i<=r;i++)
		if(y[i]*2>lim && dist(x[i]*2,y[i]*2,x[l]+x[r],lim)>(x[r]-x[l])*(x[r]-x[l]))
			return false;
	return true;
}

signed main()
{
	int a,b;
	cin >> n >> h >> a >> b;
	for(int i=1;i<=n;i++)
		scanf("%lld %lld",&x[i],&y[i]);

	memset(dp,0x3f,sizeof(dp));
	dp[1]=a*(h-y[1]);
	for(int i=2;i<=n;i++)
		for(int j=i-1;j>=1;j--)
			if(check(j,i))
				dp[i]=min(dp[i],dp[j]+a*(h-y[i])+b*(x[i]-x[j])*(x[i]-x[j]));

	if(dp[i]==0x3f3f3f3f3f3f3f3f)
		printf("impossible\n");
	else
		printf("%lld\n",dp[n]);
	return 0;
}

详细

answer.code: In function ‘int main()’:
answer.code:39:15: error: ‘i’ was not declared in this scope
   39 |         if(dp[i]==0x3f3f3f3f3f3f3f3f)
      |               ^
answer.code:30:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 |                 scanf("%lld %lld",&x[i],&y[i]);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~