Ejemplo n.º 1
0
int main(int taskD, char**bapc){
  int n, a, b;
  scanf("%d %d %d", &n, &a, &b);
  node graph[n];
  for(int i=0; i<n; i++){
    scanf("%d %d %d", &graph[i].left, &graph[i].right, &graph[i].tower);
  }
  Queue*work = newQueue();//trip
  init(n);
  push(work, newTrip(newPair(a, b), 0));
  while(!empty(work)){
    trip p = front(work); pop(work);
    if(find(p.first.first) == find(p.first.second))
      continue;
    int  d = p.second;
    node a = graph[p.first.first ];
    node b = graph[p.first.second];
    if(a.tower != b.tower){
      printf("%d\n", d);
      return 0;
    }
    dunion(p.first.first, p.first.second);
    push(work, newTrip(newPair(a.left,  b.left ), d+1));
    push(work, newTrip(newPair(a.right, b.right), d+1));
  }
  puts("indistinguishable");
  return 0;
}
Ejemplo n.º 2
0
Archivo: box.c Proyecto: vllab/pose
dbox diou(box a, box b)
{
    float u = box_union(a,b);
    float i = box_intersection(a,b);
    dbox di = dintersect(a,b);
    dbox du = dunion(a,b);
    dbox dd = {0,0,0,0};

    if(i <= 0 || 1) {
        dd.dx = b.x - a.x;
        dd.dy = b.y - a.y;
        dd.dw = b.w - a.w;
        dd.dh = b.h - a.h;
        return dd;
    }

    dd.dx = 2*pow((1-(i/u)),1)*(di.dx*u - du.dx*i)/(u*u);
    dd.dy = 2*pow((1-(i/u)),1)*(di.dy*u - du.dy*i)/(u*u);
    dd.dw = 2*pow((1-(i/u)),1)*(di.dw*u - du.dw*i)/(u*u);
    dd.dh = 2*pow((1-(i/u)),1)*(di.dh*u - du.dh*i)/(u*u);
    return dd;
}
Ejemplo n.º 3
0
Archivo: box.c Proyecto: vllab/pose
void test_dunion()
{
    box a = {0, 0, 1, 1};
    box dxa= {0+.0001, 0, 1, 1};
    box dya= {0, 0+.0001, 1, 1};
    box dwa= {0, 0, 1+.0001, 1};
    box dha= {0, 0, 1, 1+.0001};

    box b = {.5, .5, .2, .2};
    dbox di = dunion(a,b);
    printf("Union: %f %f %f %f\n", di.dx, di.dy, di.dw, di.dh);
    float inter =  box_union(a, b);
    float xinter = box_union(dxa, b);
    float yinter = box_union(dya, b);
    float winter = box_union(dwa, b);
    float hinter = box_union(dha, b);
    xinter = (xinter - inter)/(.0001);
    yinter = (yinter - inter)/(.0001);
    winter = (winter - inter)/(.0001);
    hinter = (hinter - inter)/(.0001);
    printf("Union Manual %f %f %f %f\n", xinter, yinter, winter, hinter);
}