Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class Coordinates
- {
- public:
- Coordinates() {}
- int x;
- int y;
- Coordinates(int x, int y)
- {
- this->x = x;
- this->y = y;
- }
- };
- class Hamster :public Coordinates
- {
- public:
- Hamster(int x, int y):Coordinates(x, y) {}
- float time(Coordinates & b) {
- return (abs(b.x - x) > abs(b.y - y) ? abs(b.y - y) : abs(b.x - x) );
- }
- };
- class Dog :public Coordinates
- {
- public:
- Dog(int x, int y) :Coordinates(x, y) {}
- float time(Coordinates & b) {
- return (abs(b.x - x) > abs(b.y - y) ? abs((b.y - y)/2):abs((b.x - x)/2));
- }
- };
- class Den:public Coordinates
- {
- public:
- Den() {};
- Den(int x, int y) :Coordinates(x, y) {}
- void Print()
- {
- cout << x << " " << y << endl;
- }
- };
- int main()
- {
- int x1, y1, x2, y2, n,x,y,time,k;
- cin >> x1 >> y1 >> x2 >> y2 >> n;
- Hamster FastHamster(x1, y1);
- Dog AgryDog(x2,y2);
- Den min(10000, 10000);
- Den* arr = new Den[n];
- for (int i = 0; i < n; i++)
- {
- cin >> x >> y;
- Den Cave(x, y);
- arr[i] = Cave;
- if (abs(arr[i].x-FastHamster.x)<min.x && abs(arr[i].y-FastHamster.y)<min.y)
- {
- min = arr[i];
- k = i;
- }
- }
- if(FastHamster.time(min) < AgryDog.time(min))
- cout<<k+1;
- else cout<<"NO";
- delete[] arr;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement