Problem:
Problem G: Defend the Bases

A country Gizevom is being under a sneak and fierce attack by their foe. They have to deploy one or
more troops to every base immediately in order to defend their country. Otherwise their foe would take
all the bases and declare "All your base are belong to us."

You are asked to write a program that calculates the minimum time required for deployment, given the
present positions and marching speeds of troops and the positions of the bases.

Input

The input consists of multiple datasets. Each dataset has the following format:

N M

x1 y1 v1

x2 y2 v2

...

xN yN vN

x'1 y'1

x'2 y'2

...

x'M y'M

N is the number of troops (1 ≤ N ≤ 100); M is the number of bases (1 ≤ M ≤ 100); (xi, yi ) denotes the present position of i-th troop; vi is the speed of the i-th troop (1 ≤ vi ≤ 100); (x'j, y'j) is the position of the j-th base.

All the coordinates are integers between 0 and 10000 inclusive.

The last dataset is followed by a line containing two zeros. This line is not a part of any dataset and should not be processed.

Output

For each dataset, print the minimum required time in a line.

Sample Input

2 2
10 20 1
0 10 1
0 10
10 0
0 0

Output for the Sample Input

14.14213562

Solution in C++ (judge verdict: Wrong Answer)

#include<bits/stdc++.h>
using namespace std;

int n,m;
double x[100],y[100],v[100];
double px[100],py[100];
double t[100][100];
vector<int> G[200];

void add_edge(int u,int v){
  G[u].push_back(v);
  G[v].push_back(u);
}

int match[200],used[200];

bool dfs(int v){
  used[v]=true;
  for(int i=0;i<(int)G[v].size();i++){
    int u=G[v][i],w=match[u];
    if(w<0||(!used[w]&&dfs(w))){
      match[v]=u;
      match[u]=v;
      return true;
    }
  }
}

int bipartite_matching(){
  int res=0;
  memset(match,-1,sizeof(match));
  for(int v=0;v<n+m;v++){
    if(match[v]<0){
      memset(used,0,sizeof(used));
      if(dfs(v))res++;
    }
  }
  return res;
}

bool check(double X){
  for(int i=0;i<n+m;i++)G[i].clear();
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)
      if(t[i][j]<X-0.000000001)
        add_edge(i,n+j);
  if(bipartite_matching()==m)return true;
  return false;
}

double solve(){
  double l=0,r=1e8,m;
  for(int i=0;i<200;i++){
    m=(l+r)*0.5;
    if(check(m))r=m;
    else l=m;
  }
  return l;
}

int main(){
  while(1){
    cin>>n>>m;
    if(n==0&&m==0)break;
    for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>v[i];
    for(int i=0;i<m;i++)cin>>px[i]>>py[i];
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
        double dx=x[i]-px[j];
        double dy=y[i]-py[j];
        t[i][j]=sqrt(dx*dx+dy*dy)/v[i];
      }
    }
    printf("%.10f\n",solve());
  }
  return 0;
}