CF598F.Cut Length

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Given simple (without self-intersections) nn -gon. It is not necessary convex. Also you are given mm lines. For each line find the length of common part of the line and the nn -gon.

The boundary of nn -gon belongs to polygon. It is possible that nn -gon contains 180-degree angles.

输入格式

The first line contains integers nn and mm ( 3<=n<=1000;1<=m<=1003<=n<=1000;1<=m<=100 ). The following nn lines contain coordinates of polygon vertices (in clockwise or counterclockwise direction). All vertices are distinct.

The following mm lines contain line descriptions. Each of them contains two distict points of a line by their coordinates.

All given in the input coordinates are real numbers, given with at most two digits after decimal point. They do not exceed 10510^{5} by absolute values.

输出格式

Print mm lines, the ii -th line should contain the length of common part of the given nn -gon and the ii -th line. The answer will be considered correct if the absolute or relative error doesn't exceed 10610^{-6} .

输入输出样例

  • 输入#1

    4 3
    0 0
    1 0
    1 1
    0 1
    0 0 1 1
    0 0 0 1
    0 0 1 -1
    

    输出#1

    1.41421356237309514547
    1.00000000000000000000
    0.00000000000000000000
    
首页