洛谷P1003 铺地毯
第一次交:
很奇怪这是为什么,明明很快就出结果了,12s不要太夸张,后来只改了一个字符:‘~’
出乎意料的绿了,居然是因为while中scanf前面没有加~,一定要注意这个问题呀,AC代码:
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cctype>
#include <stack>
#include <list>
#include <queue>
#include <cmath>
#include <vector>
typedef long long ll;
using namespace std;
//const double pi=acos(-1);
struct point{
int x,y;
int lx,ly;
};
const int maxn=10005;
point p[maxn];
bool isIn(point sq,point po){
if(po.x>=sq.x&&po.x<=sq.x+sq.lx&&po.y>=sq.y&&po.y<=sq.y+sq.ly){
return true;
}
return false;
}
int main(){
int n,a,b,g,k,x,y;
while (~scanf("%d",&n)) {
for(int i=1;i<=n;i++){
scanf("%d%d%d%d",&a,&b,&g,&k);
p[i].x=a;
p[i].y=b;
p[i].lx=g;
p[i].ly=k;
}
scanf("%d%d",&x,&y);
point d;
d.x=x;d.y=y;
int fl=0;
for(int i=n;i>=1;i--){
if(isIn(p[i], d)){
cout<<i<<endl;
fl=1;
break;
}
}
if(!fl){
cout<<-1<<endl;
}
}
return 0;
}