#include <bits/stdc++.h>
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
#define F first
#define S second
#define PB push_back
#define M ll(1e9 + 7)
#define sz(x) (ll)x.size()
#define N 200500
#define pri(x) cout << x << endl
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define _ << " " <<
using namespace std;
//typedef tree <ll, null_type, less_equal <ll> , rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef short int si;
typedef unsigned long long ull;
const ld eps = 1e-10;
int n, h;
ld dst(ld x1, ld y1, ld x2, ld y2)
{
ld a = x1 - x2;
ld b = y1 - y2;
a *= a;
b *= b;
a += b;
return sqrt(a);
}
bool gd(int x1, int y1, int x2, int y2, int x, int y)
{
ld len1 = dst(x1, y1, x, y);
ld len2 = dst(x2, y2, x, y);
ll val1 = (y1 - y);
ll val2 = (y2 - y);
len1 = ld(val1) / len1;
len2 = ld(val2) / len2;
if (len2 - len1 > eps)
return 0;
return 1;
}
int main()
{
istream::sync_with_stdio(0); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> h;
int x[n], y[n];
for (int i = 0; i < n; i++)
cin >> x[i] >> y[i];
vector <pair <int, int> > vr; vr.clear();
for (int i = 2; i < n - 1; i += 2)
{
int l = -1e6;
int r = x[i - 1];
while (l < r)
{
int md = (l + r) >> 1;
if (gd(md, h, x[i - 1], y[i - 1], x[i], y[i]))
r = md;
else l = md + 1;
}
int L = x[i + 1], R = 1e6;
while (L < R)
{
int md = (L + R + 1) >> 1;
if (gd(md, h, x[i + 1], y[i + 1], x[i], y[i]))
L = md;
else R = md - 1;
}
vr.PB({l, L});
}
int ans = 0;
sort(all(vr));
for (int i = 0; i < n; )
{
int j = i + 1;
int mn = vr[i].S;
while (j < n)
{
if (mn < vr[j].F)
break;
mn = min(mn, vr[j].S);
j++;
}
ans++;
i = j;
}
pri(ans);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
324 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |