QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#398716 | #2338. Beautiful Bridges | BIXIAN | WA | 0ms | 4048kb | C++14 | 1.7kb | 2024-04-25 17:01:53 | 2024-04-25 17:01:53 |
Judging History
answer
#include<iostream>
using namespace std;
int f[100001];
int n, h, a, d,ans,w;
int s[100001][2];
bool df(int a, int b)
{
double midx = ((double)a + (double)b) / 2;
double midy = h - ((double)b - (double)a) / 2;
if(midy<0)
return 0;
double r = ((double)b - (double)a) / 2;
for (int i = a; i <= b; i++)
{
if (f[a]>=0)
{
if ((f[a]>=midy)&&((midx - (double)a) * (midx - (double)a) + (midy - (double)f[a]) * (midy - (double)f[a]))>(r*r))
return 0;
}
}
return 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];
w += a*(h - f[x]);
ans++;
s[ans][0] = x;
if (f[x] > max1)
max1 = f[x];
}
bool v = 0;
for (int i = 1; i < ans; i++)
{
v = 0;
for (int j = i + 1; j <= ans; j++)
{
if ((df(s[i][0], s[j][1])))
{
v = 1;
s[i][1] = j;
w += d * ((s[j][0] - s[i][0]) * (s[j][0] - s[i][0]));
i = j - 1;
break;
}
}
if(!v)
cout<< "impossible";
}
if(v)
{
while (1)
{
int yy = 1;
bool v = 1;
while (yy != ans && s[yy][1] != ans)
{
if (df(s[yy][0], s[s[s[yy][1]][1]][0]))
{
int qw = h - f[s[s[yy][1]][0]];
int qe = (s[s[s[yy][1]][1]][0] - s[yy][0]) * (s[s[s[yy][1]][1]][0] - s[yy][0]);
int qe1 = (s[s[s[yy][1]][1]][0] - s[s[yy][1]][0]) * (s[s[s[yy][1]][1]][0] - s[s[yy][1]][0]);
int qe2 = (s[s[yy][1]][0] - s[yy][0]) * ((s[s[yy][1]][0] - s[yy][0]));
if (a * qw > d * (qe - qe1 - qe2))
{
v = 0;
s[yy][1] = s[s[yy][1]][1];
w -= a * qw - d * (qe - qe1 - qe2);
}
}
yy = s[yy][1];
}
if (v)
break;
}
cout << w;
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 4032kb
input:
5 60 18 2 0 0 20 20 30 10 50 30 70 20
output:
6460
result:
ok single line: '6460'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 4048kb
input:
4 10 1 1 0 0 1 9 9 9 10 0
output:
88
result:
wrong answer 1st lines differ - expected: 'impossible', found: '88'