Skip to content

Instantly share code, notes, and snippets.

@asi1024
Created July 25, 2014 03:06
Show Gist options
  • Save asi1024/7e53ebbb5a43c450b1c2 to your computer and use it in GitHub Desktop.
Save asi1024/7e53ebbb5a43c450b1c2 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <queue>
#include <algorithm>
#include <complex>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef double ld;
typedef complex<ld> P;
const ld INF = 1e12;
const ld pi = acos(-1.0);
const int M = 13000;
ld dist[32][32][32];
ld dp[M][22][22];
int main() {
int n;
ld r, theta, x, y;
cin >> n >> r >> theta;
vector<P> p(n);
REP(i,n) {
cin >> x >> y;
p[i] = P(x, y);
}
REP(i,n) REP(j,n) REP(k,n) dist[i][j][k] = INF;
REP(i,n) REP(j,n) REP(k,n) {
if (i == j || j == k) continue;
P next = p[k] - p[j];
P prev = p[j] - p[i];
if (abs(arg(next / prev)) < theta / 180.0 * pi)
dist[i][j][k] = abs(next);
}
REP(c,M) REP(i,n) REP(j,n) dp[c][i][j] = INF;
for (int j = 1; j < n; j++)
dp[0][0][j] = abs(p[0] - p[j]);
int res = 0;
REP(c,M-1) REP(i,n) REP(j,n) REP(k,n) {
dp[c+1][j][k] = min(dp[c+1][j][k], dp[c][i][j] + dist[i][j][k]);
if (dp[c][i][j] < r) res = c + 1;
}
cout << res << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment