p1003;0分求助
查看原帖
p1003;0分求助
1399179
xyfc楼主2024/7/22 21:19

###0分求助! ##p1003; #代码如下:

#include<iostream>
using namespace std;
struct dt{
 int x,y;//左下角坐标 
 int xc,yc;//x,y长度
}xh[10010];//地毯序号 
int main()
{
 int fg[999999][999999]={0};//该坐标最上层覆盖
 long long zb[99999999][99999999]={0};//坐标 
 int n;
 cin>>n;//地毯 
 for(int i=0;i<=n-1;i++){
   cin>>xh[i].x;
   cin>>xh[i].y;
   cin>>xh[i].xc;
   cin>>xh[i].yc;//输入地毯信息
   for(int jx=xh[i].x;jx<=xh[i].xc+xh[i].x;jx++){//x方向从x到jx之间,重复jx-x次 
     for(int jy=xh[i].y;jy<=xh[i].yc+xh[i].y;jy++){//x方向从y到jy之间,重复jy-y次 
       zb[jy][jy]=1;//将地毯区域设为已覆盖
   	zb[jy][jy]=i;//更新该坐标最上层覆盖 
   }
   } 
 }
 int x,y;//定义所求坐标
 cin>>x>>y;//输入所求坐标
 if (zb[x][y]==1)cout<<fg;//如果被覆盖,输出该坐标最上层覆盖 
 else cout<<"-1" ;//否则输出"-1" 
 return 0;
} 
  ``` ```
2024/7/22 21:19
加载中...