QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#398763#2338. Beautiful BridgesBIXIANCompile Error//C++141.4kb2024-04-25 18:01:512024-04-25 18:01:52

Judging History

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

  • [2024-04-25 18:01:52]
  • 评测
  • [2024-04-25 18:01:51]
  • 提交

answer

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

详细

answer.code: In function ‘int main()’:
answer.code:66:9: error: ‘memset’ was not declared in this scope
   66 |         memset(qw, 0x3f3f, sizeof(qw));
      |         ^~~~~~
answer.code:3:1: note: ‘memset’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’?
    2 | #include<algorithm>
  +++ |+#include <cstring>
    3 | using namespace std;