Python - necesito ayuda para pasar este codigo a python urgente

 
Vista:

necesito ayuda para pasar este codigo a python urgente

Publicado por daniel (1 intervención) el 26/11/2018 04:09:28
este es el link del codigo
https://github.com/morris821028/UVa/blob/master/volume100/10080%20-%20Gopher%20II.cpp


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <stdio.h>
#include <string.h>
#include <math.h>
int map[202][202], mt[202];
int mx[202], my[202], used[202];
int dfs(int x) {
    int i, y;
    for(i = 0; i < mt[x]; i++) {
        y = map[x][i];
        if(!used[y]) {
            used[y] = 1;
            if(my[y] == 0 || dfs(my[y])) {
                mx[x] = y, my[y] = x;
                return 1;
            }
        }
    }
    return 0;
}
int main() {
    int n, m, s, v, i, j;
    while(scanf("%d %d %d %d", &n, &m, &s, &v) == 4) {
        double g[101][2], h[101][2];
        for(i = 1; i <= n; i++)
            scanf("%lf %lf", &g[i][0], &g[i][1]);
        for(i = 1; i <= m; i++)
            scanf("%lf %lf", &h[i][0], &h[i][1]);
        memset(mt, 0, sizeof(mt));
        memset(mx, 0, sizeof(mx));
        memset(my, 0, sizeof(my));
 
        for(i = 1; i <= n; i++) {
            for(j = 1; j <= m; j++) {
                if(sqrt((g[i][0]-h[j][0])*(g[i][0]-h[j][0])+
                        (g[i][1]-h[j][1])*(g[i][1]-h[j][1]))/v <= s) {
                    map[i][mt[i]++] = n+j;
                }
            }
        }
        int ans = 0;
        for(i = 1; i <= n; i++) {
            if(!mx[i]) {
                memset(used, 0, sizeof(used));
                if(dfs(i))
                    ans++;
            }
        }
        printf("%d\n", n-ans);
    }
    return 0;
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
-3
Responder