青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

ZOJ 1081 Points Within

Points Within

Time limit: 1 Seconds   Memory limit: 32768K  
Total Submit: 2222   Accepted Submit: 566  

Statement of the Problem

Several drawing applications allow us to draw polygons and almost all of them allow us to fill them with some color. The task of filling a polygon reduces to knowing which points are inside it, so programmers have to colour only those points.

You're expected to write a program which tells us if a given point lies inside a given polygon described by the coordinates of its vertices. You can assume that if a point is in the border of the polygon, then it is in fact inside the polygon.

Input Format

The input file may contain several instances of the problem. Each instance consists of: (i) one line containing integers N, 0 < N < 100 and M, respectively the number of vertices of the polygon and the number of points to be tested. (ii) N lines, each containing a pair of integers describing the coordinates of the polygon's vertices; (iii) M lines, each containing a pair of integer coordinates of the points which will be tested for "withinness" in the polygon.

You may assume that: the vertices are all distinct; consecutive vertices in the input are adjacent in the polygon; the last vertex is adjacent to the first one; and the resulting polygon is simple, that is, every vertex is incident with exactly two edges and two edges only intersect at their common endpoint. The last instance is followed by a line with a 0 (zero).

Output Format

For the ith instance in the input, you have to write one line in the output with the phrase "Problem i:", followed by several lines, one for each point tested, in the order they appear in the input. Each of these lines should read "Within" or "Outside", depending on the outcome of the test. The output of two consecutive instances should be separated by a blank line.

Sample Input

3 1
0 0
0 5
5 0
10 2
3 2
4 4
3 1
1 2
1 3
2 2
0

Sample Output

Problem 1:
Outside

Problem 2:
Outside
Within


Problem Source: South America 2001
Analysis
Algorithm:
This problem is simple to understand. In order to determine the given point whether it is inner, initially, we should exclude the situation of the online occurrence. Be careful of the points which is an component of the polygon. And later, draw a directed line randomly and count the crossing points. If it is even, it is obviously inner and true for another situation: the point is outside when the result is odd.

code
 
#include <iostream>   
using namespace std;   
struct point{   
    
int x, y;   
}
;   
struct line{   
    point p1, p2;   
}
;   
const int MAXN = 101;   
const int MAX = 99999999;   
point p[MAXN];   
int m, n;   
inline 
int max(line l){   
    
return (l.p1.y > l.p2.y ? l.p1.y : l.p2.y);   
}
   
inline 
int min(line l){   
    
return (l.p1.y > l.p2.y ? l.p2.y : l.p1.y);   
}
   
inline 
int xmult(int x1, int y1, int x2, int y2){   
    
return x1 * y2 - x2 * y1;   
}
   
inline 
int pmult(int x1, int y1, int x2, int y2){   
    
return x1 * x2 + y1 * y2;   
}
   
inline 
int cmp(int x){   
    
if (x == 0return 0;   
    
if (x < 0return -1;   
    
if (x > 0return 1;   
}
   
inline 
int cross(point a, point b, point c){   
    
return cmp(xmult(b.x - a.x, b.y - a.y, c.x - a.x, c.y - a.y));   
}
   
inline 
int linecross(line l1, line l2){   
    
return (cross(l1.p1, l2.p1, l2.p2) * cross(l1.p2, l2.p1, l2.p2) < 0   
        
&& cross(l2.p1, l1.p1, l1.p2) * cross(l2.p2, l1.p1, l1.p2) < 0);   
}
   
int test(point tp){   
    line poly, t;   
    
int x = 0;   
    t.p1 
= tp; t.p2.x = 1280213; t.p2.y = 321123;   
    
for (int i = 0; i != n; ++i){   
        
if (i == n - 1){   
            poly.p1 
= p[n - 1]; poly.p2 = p[0];   
        }
 else {   
            poly.p1 
= p[i]; poly.p2 = p[i + 1];   
        }
   
        
while(online(poly.p1,t.p1,t.p2)||online(poly.p2,t.p1,t.p2)) {t.p2.x++;t.p2.y++;}
        
if (linecross(poly, t)) ++x;   
    }
   
    
if (x % 2return 1else return 0;   
}
   
  
int online(point tp, point a, point b){   
    
if (cmp(xmult(tp.x - a.x, tp.y - a.y, b.x - a.x, b.y - a.y)) == 0 &&   
        cmp(pmult(tp.x 
- a.x, tp.y - a.y, tp.x - b.x, tp.y - b.y)) < 0 ) return 1else return 0;   
}
   
int checkonline(point tp){   
    
for (int i = 0; i != n; ++i){   
        
if (tp.x == p[i].x && tp.y == p[i].y) return 1;   
    }
   
    
for (int i = 0; i != n - 1++i){   
        
if (online(tp, p[i], p[i + 1])) return 1;   
    }
   
    
if (online(tp, p[n - 1], p[0])) return 1else return 0;   
}
   
int main(){   
    
int cases = 0;   
    point tp;   
    
while (cin >> n && n != 0){   
        cin 
>> m;   
        
++cases;   
        
if (cases != 1) cout << endl;   
        
for (int i = 0; i != n; ++i) cin >> p[i].x >> p[i].y;   
        cout 
<< "Problem " << cases << ":" << endl;   
        
for (int i = 0; i != m; ++i){   
            cin 
>> tp.x >> tp.y;   
            
if (checkonline(tp)){   
                cout 
<< "Within" << endl;   
                
continue;   
            }
   
            
if (test(tp)) cout << "Within" << endl; else cout << "Outside" << endl;   
        }
   
    }
   
    
return 0;   
}
  

posted on 2008-08-09 21:02 幻浪天空領主 閱讀(463) 評論(0)  編輯 收藏 引用 所屬分類: ZOJ


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


<2025年12月>
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

導航

統計

常用鏈接

留言簿(1)

隨筆檔案(2)

文章分類(23)

文章檔案(22)

搜索

最新評論

閱讀排行榜

評論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            噜噜噜噜噜久久久久久91| 免费成人av| 国产亚洲欧美日韩精品| 欧美亚洲一区二区三区| 欧美一级专区免费大片| 伊人久久噜噜噜躁狠狠躁| 亚洲第一网站| 欧美精品一区二| 欧美一级专区| 久久躁日日躁aaaaxxxx| 亚洲三级影院| 亚洲午夜羞羞片| 亚洲国产成人av在线| 亚洲精品日本| 国内久久视频| 亚洲精品久久久一区二区三区| 欧美色图五月天| 久久久久高清| 欧美人与性动交cc0o| 欧美伊人精品成人久久综合97| 久久久福利视频| 亚洲私拍自拍| 久久久亚洲国产美女国产盗摄| 日韩天堂在线视频| 香蕉免费一区二区三区在线观看| 亚洲福利视频免费观看| 亚洲手机在线| 亚洲国产裸拍裸体视频在线观看乱了中文 | 中国女人久久久| 狠久久av成人天堂| 夜夜爽www精品| 亚洲丰满少妇videoshd| 亚洲午夜激情免费视频| 亚洲国产精品久久久久婷婷884| 亚洲美女淫视频| 极品日韩久久| 亚洲综合精品| 日韩亚洲精品电影| 久久久国产亚洲精品| 亚洲综合日本| 欧美巨乳在线| 欧美激情精品久久久久| 国产亚洲欧洲997久久综合| 亚洲精品国产系列| 在线不卡a资源高清| 亚洲一区欧美一区| 在线亚洲欧美专区二区| 久久久久国产精品厨房| 香蕉久久一区二区不卡无毒影院| 欧美二区视频| 久久综合久色欧美综合狠狠 | 国产欧美日韩视频一区二区| 亚洲国产另类精品专区| 国户精品久久久久久久久久久不卡| 最新日韩中文字幕| 亚洲黄色大片| 久久综合99re88久久爱| 久久婷婷麻豆| 国产在线拍偷自揄拍精品| 亚洲午夜激情| 亚洲欧美亚洲| 国产精品久久综合| 亚洲一区二区欧美日韩| 亚洲欧美成人一区二区在线电影| 欧美日韩1区2区| 亚洲精品日韩一| 亚洲视屏在线播放| 欧美午夜无遮挡| 中国成人在线视频| 亚洲欧美日韩直播| 国产精品一区二区久久精品| 亚洲视频一区在线| 午夜精品短视频| 国产日韩在线看片| 午夜亚洲性色福利视频| 久久久久www| 精品动漫3d一区二区三区| 久久欧美肥婆一二区| 欧美www视频| 亚洲精品日韩在线| 欧美日韩蜜桃| 亚洲自拍偷拍色片视频| 久久久久久亚洲综合影院红桃| 国模 一区 二区 三区| 久久午夜视频| 亚洲美女区一区| 午夜一区二区三区不卡视频| 国产精品综合网站| 久久精品男女| 亚洲黄色影片| 亚洲欧美日韩在线观看a三区| 国产欧亚日韩视频| 玖玖在线精品| 亚洲天堂网在线观看| 久久久久综合网| 99精品国产热久久91蜜凸| 国产精品久久久久久五月尺| 久久不射网站| 亚洲欧洲三级| 久久精品人人做人人爽| 亚洲日产国产精品| 国产精品盗摄久久久| 久久久久久久国产| 一区二区三区三区在线| 美女黄色成人网| 亚洲男人的天堂在线aⅴ视频| 激情文学一区| 国产精品捆绑调教| 免费观看一区| 亚洲欧美综合v| 最近中文字幕日韩精品 | 日韩五码在线| 久久久久在线观看| 亚洲主播在线| 91久久综合亚洲鲁鲁五月天| 国产精品久久九九| 欧美粗暴jizz性欧美20| 亚洲欧美日韩在线播放| 亚洲三级色网| 嫩模写真一区二区三区三州| 香蕉乱码成人久久天堂爱免费| 91久久国产自产拍夜夜嗨| 国产日韩av高清| 国产精品日韩欧美综合| 欧美日韩精品一二三区| 免费在线欧美视频| 久久精品夜色噜噜亚洲aⅴ| 亚洲免费在线播放| 妖精视频成人观看www| 亚洲激情视频在线观看| 蜜臀av性久久久久蜜臀aⅴ| 午夜久久久久| 亚洲一区二区三区免费观看| 亚洲精品在线免费| 亚洲国产成人在线视频| 激情婷婷亚洲| 尤妮丝一区二区裸体视频| 国产欧美日韩精品a在线观看| 欧美视频一区二区在线观看| 欧美区二区三区| 欧美激情欧美狂野欧美精品| 免费久久精品视频| 美女91精品| 欧美va亚洲va国产综合| 乱人伦精品视频在线观看| 久久久99国产精品免费| 久久精品国产91精品亚洲| 久久黄色网页| 久久久久久欧美| 狂野欧美激情性xxxx欧美| 美女视频一区免费观看| 欧美xx视频| 欧美精品aa| 欧美日韩在线不卡| 国产精品成人一区二区艾草| 国产精品国产三级国产专播精品人| 欧美日韩成人| 国产精品国产三级国产aⅴ入口 | 久久综合综合久久综合| 欧美mv日韩mv国产网站app| 欧美阿v一级看视频| 欧美日韩国产精品| 欧美午夜精品久久久久久孕妇| 欧美亚洲成人免费| 欧美午夜视频在线观看| 国产午夜精品一区理论片飘花| 黑人一区二区三区四区五区| 伊人久久大香线蕉综合热线| 亚洲精品久久久久久久久| 中文国产亚洲喷潮| 久久九九免费视频| 欧美成人情趣视频| 一本综合久久| 久久激情视频| 欧美全黄视频| 国产一区深夜福利| 亚洲精品一区二区三区99| 亚洲制服av| 欧美成人亚洲| 亚洲一区二区三区涩| 久久青草福利网站| 国产精品国产a级| 亚洲第一伊人| 午夜精品久久久久久久99樱桃| 久久综合狠狠| 亚洲午夜视频| 欧美黄色精品| 国产精品日韩欧美一区二区| 亚洲高清影视| 久久精品国产精品亚洲综合| 最新成人av网站| 久久久在线视频| 国产精品久久午夜夜伦鲁鲁| 91久久国产自产拍夜夜嗨| 久久se精品一区精品二区| 亚洲毛片视频| 免费视频久久| 激情欧美亚洲| 久久久不卡网国产精品一区| 99国内精品|