Commits

Jure Žbontar  committed 883b4db

dog_and_gopher

  • Participants
  • Parent commits 1b9e986

Comments (0)

Files changed (1)

File dog_and_gopher.cpp

+#include <algorithm>
+#include <bitset>
+#include <cassert>
+#include <cmath>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <ctime>
+#include <deque>
+#include <functional>
+#include <iomanip>
+#include <iostream>
+#include <list>
+#include <map>
+#include <numeric>
+#include <queue>
+#include <set>
+#include <sstream>
+#include <stack>
+#include <utility>
+#include <vector>
+
+using namespace std;
+
+typedef vector<int> vi;
+
+#define sz(a) int((a).size()) 
+#define all(c) (c).begin(), (c).end()
+#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
+
+int main() {
+	int holes;
+	double gx, gy, dx, dy;
+
+	while (cin >> holes >> gx >> gy >> dx >> dy) {
+		int escape = 0;
+		for (int i = 0; i < holes; i++) {
+			double hx, hy;
+
+			cin >> hx >> hy;
+			if (escape)
+				continue;
+
+			double gd = (gx - hx) * (gx - hx) + (gy - hy) * (gy - hy);
+			double dd = (dx - hx) * (dx - hx) + (dy - hy) * (dy - hy);
+			if (gd * 4 <= dd) {
+				printf("The gopher can escape through the hole at (%.3f,%.3f).\n", hx, hy);
+				escape = 1;
+			}
+		}
+		if (!escape)
+			printf("The gopher cannot escape.\n");
+	}
+}
+