luogu P1003 铺地毯
1 #include <iostream> 2 using namespace std; 3 int main() 4 { 5 int n,x,y; 6 int x1[11000],y1[11000],lx[11000],ly[11000]; 7 cin >> n; 8 for (int i = 1;i <= n;i++) 9 cin >> x1[i] >> y1[i] >> lx[i] >> ly[i]; 10 cin >> x >> y; 11 for (int i = n;i >= 1;i--) 12 { 13 if ((x1[i] <= x && x <= x1[i] + lx[i]) && (y1[i] <= y && y <= y1[i] + ly[i])) 14 { 15 cout << i << endl; 16 return 0; 17 } 18 } 19 //如果在这个位置还没有结束程序 20 cout << -1 << endl; 21 return 0; 22 }
心之所动 且就随缘去吧