小题解(半暴力
2024-02-05 15:07:47
发布于:广东
57阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int n,sum=-1,q[11000][10],a,b,x,y;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>q[i][0]>>q[i][1]>>a>>b;
q[i][2]=q[i][0]+a;
q[i][3]=q[i][1]+b;
}
cin>>x>>y;
for(int i=n;i>=1;i--){
if(x>=q[i][0]&&x<=q[i][2]&&y>=q[i][1]&&y<=q[i][3]){
sum=i;
break;
}
}
cout<<sum<<endl;
return 0;
}
全部评论 1
#include <bits/stdc++.h> using namespace std; long long n, x, y; const long long N = 101100; long long a [N], b[N], c[N], d[N]; int main() { cin >> n; for (int i = 1 ; i <= n ; i++) { scanf ("%d%d%d%d", & a[i], & b[i], & c[i], & d[i]); } scanf ("%d%d", &x, &y); long long color = 0; for (int j = 1 ; j <= n ; j++) { if (a[j] <= x && c[j] + a[j] >= x && b[j] <= y && b[j] + d[j] >= y) { color = j; } } cout << color; return 0; }
1周前 来自 福建
0
有帮助,赞一个