• [1183] Dawn of the Dead

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • One day, after XadillaX waken up, he found that the whole city is strange - everyone become a zombie except him.
    So he decided to wait for the helicopter saving him.
    This city is a square field that (N * N) square miles, XadillaX is at (0, 0) and helicopter is at (N, N). And there're some high walls block off the helicopter.
    The helicopter cannot go through the high walls, but it can go around them.
    The helicopter wants to arrive at the point that XadillaX is at as soon as possible.
    What are the minimum miles the helicopter should go?


  • 输入
  • This problem contains several cases.
    The first line of each case are two numbers, N and M. N indicates the side length of the city and M is the number of walls. (1.0 <= N <= 100.0, 0 <= M <= 50)
    Then follow M lines. Each line has two coordinates x1 y1 x2 y2, indicates the WALLi. You can assume that no two walls are intersected.
  • 输出
  • For each case, you should print the minimum miles that the helicopter should go, two decimal places.
  • 样例输入
  • 10 3
    1.0 1.0 1.0 5.0
    9.0 5.0 9.0 9.0
    5.0 2.5 5.0 7.5
    10 1
    1.0 1.0 9.0 9.0
    
  • 样例输出
  • 14.64
    14.14
    
  • 提示
  • 来源
  • XadillaX
  • 操作

显示春菜