洛谷普及试炼场之旅
A. 简单模拟
铺地毯:就是模拟
1 #include<cstdio> 2 #include<iostream> 3 #define maxn 10000000 4 using namespace std; 5 6 struct parpet{ 7 int x1,x2,y1,y2; 8 }list[maxn]; 9 10 int n,a,b,c,d,ansx,ansy,ans; 11 12 bool Judge(parpet &A,int x,int y){ 13 return (A.x1 <= x)&&(x <= A.x2)&&(A.y1 <= y)&&(y <= A.y2); 14 } 15 16 int main(){ 17 scanf("%d",&n); 18 for(int i = 0;i < n;i++){ 19 scanf("%d%d%d%d",&a,&b,&c,&d); 20 list[i].x1 = a; 21 list[i].y1 = b; 22 list[i].x2 = a+c; 23 list[i].y2 = b+d; 24 }scanf("%d%d",&ansx,&ansy); 25 ans = -1; 26 for(int i = 0;i < n;i++){ 27 if(Judge(list[i],ansx,ansy)) ans = i+1; 28 } 29 30 printf("%d",ans); 31 }
转载请注明出处 -- 如有意见欢迎评论