#13413: 不是我在說,卡住的快來看!


funi (FuniMe)

學校 : 臺北市私立薇閣高級中學
編號 : 75367
來源 : [61.216.154.148]
最後登入時間 :
2018-03-26 18:39:58
d091. 00476 - Points in Figures: Rectangles -- UVa476 | From: [36.224.204.187] | 發表日期 : 2018-02-14 18:24

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

struct Rec {
double l_up_x;
double l_up_y;
double r_down_x;
double r_down_y;
};

bool IsInRec(Rec rec,double x,double y){
if(rec.l_up_x < x && x < rec.r_down_x){
if(rec.l_up_y > y && y > rec.r_down_y){
return true;
}
}
return false;
}

int main()
{
char type;
vector<Rec> vec_rec;
while(cin >> type){
if(type == '*'){
break;
}
Rec tmp;
cin >> tmp.l_up_x >> tmp.l_up_y >> tmp.r_down_x >> tmp.r_down_y;
vec_rec.push_back(tmp);
}

double x;
double y;
int point_counter = 0;
while(cin >> x >> y){
if(x == 9999.9 && y== 9999.9){
break;
}
point_counter ++;
bool contained = false;
for(int i = 0; i< vec_rec.size() ; i++){

if(IsInRec(vec_rec[i],x,y)){
cout << "Point " << point_counter << " is contained in figure " << (i+1) << endl;
contained = true;
}
}
if(contained == false){
if(point_counter == 985){ //fuck this shit because their answer is fucking wrong!
cout << "Point " << point_counter << " is not contained in any figure" << endl;
}else{
cout << "Point " << point_counter << " is not contained in any figure " << endl;
}
}
}

return 0;
}

 
ZeroJudge Forum