问答 源码:
#import "bits/stdc++.h"
#define ll long long
#define endl '\n'
#define max(x, y) (x > y ? x : y)
#define min(x, y) (x < y ? x : y)
#define pii pair<int, int>
#define piii pair<int, pii>
#define pdd pair<double, double>
using namespace std;
const int N = 1e5 + 1;
ll n, d;
double ttx, tty;
pdd a[N], c[N];
bool cmp(pdd tx, pdd ty) { return tx.second < ty.second; }
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> d;
for(int i = 1; i<=n; i++) { cin >> a[i].first >> a[i].second; }
for(int i = 1; i <= n; i ++) {
int x = a[i].first, y = a[i].second;
int w = 4 * x * x + 4 * (d * d - x * x - y * y);
if(w >= 0) {
c[i].first = x - (sqrt(w))/2;
c[i].second = x + (sqrt(w))/2;
} else { goto Loop; }
}
sort(c + 1, c + n + 1, cmp);
double where=c[1].second;
int Answer = 1;
for(int i = 1; i <= n; i ++) {
if(c[i].first > where) {
Answer ++;
where = c[i].second;
}
}
cout << Answer << endl;
return 0;
Loop:
cout << -1 << endl;
return 0;
}
a.cpp:1:2: warning: #import is a deprecated GCC extension [-Wdeprecated]
1 | #import "bits/stdc++.h"
| ^~~~~~
a.cpp: In function 'int main()':
a.cpp:50:1: error: jump to label 'Loop'
50 | Loop:
| ^~~~
a.cpp:31:17: note: from here
31 | } else { goto Loop; }
| ^~~~
a.cpp:37:6: note: crosses initialization of 'int Answer'
37 | int Answer = 1;
| ^~~~~~
a.cpp:36:9: note: crosses initialization of 'double where'
36 | double where=c[1].second;
| ^~~~~