铺地毯
铺地毯
https://ac.nowcoder.com/acm/problem/16593
简单暴力枚举;
#include<bits/stdc++.h> using namespace std; struct node{ int a,b,g,k; }nod[110000];//分别记录四个顶点 int main() { int n; cin>>n; for(int i=1;i<=n;i++) { int a,b,g,k; cin>>a>>b>>g>>k; nod[i].a=a,nod[i].b=b,nod[i].g=a+g,nod[i].k=b+k; } int x,y,ok=0; cin>>x>>y; for(int i=n;i>=1;i--) { if((nod[i].a<=x&&nod[i].g>=x&&nod[i].b<=y&&nod[i].k>=y)) {ok=i;break;} }//倒序枚举点,如果覆盖该点则break if(ok) cout<<ok; else cout<<-1; }