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

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 幻浪天空領(lǐng)主 閱讀(463) 評(píng)論(0)  編輯 收藏 引用 所屬分類: ZOJ


只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


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

導(dǎo)航

統(tǒng)計(jì)

常用鏈接

留言簿(1)

隨筆檔案(2)

文章分類(23)

文章檔案(22)

搜索

最新評(píng)論

閱讀排行榜

評(píng)論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            一区二区三区视频观看| 亚洲精品国产品国语在线app| 亚洲欧美日韩第一区| 久久国产精品高清| 伊人精品成人久久综合软件| 免费人成精品欧美精品| 日韩视频精品| 欧美在线视频在线播放完整版免费观看 | 久久精品人人做人人综合| 国外成人在线视频| 欧美高清视频免费观看| 亚洲深夜福利网站| 久久久久一本一区二区青青蜜月| 亚洲福利视频网| 国产精品免费看| 久久人人爽人人爽爽久久| 亚洲精品中文字幕有码专区| 久久国产精品久久精品国产| 在线免费一区三区| 国产精品二区二区三区| 久久久久一区二区三区| 99国产精品久久久久久久| 久久久久久亚洲精品杨幂换脸| 亚洲欧洲一区二区三区| 国产情人节一区| 欧美激情亚洲一区| 欧美一区二区精品| 日韩一级视频免费观看在线| 久久人人97超碰精品888| avtt综合网| 精品99视频| 国产欧美一区二区三区国产幕精品| 久久综合色88| 欧美在线综合视频| 艳女tv在线观看国产一区| 欧美a级一区二区| 久久国产精品亚洲77777| 亚洲网站视频| 亚洲精品一区二区三区福利| 国产午夜精品一区二区三区视频 | 欧美一级理论片| 亚洲美女黄网| 欧美黄色网络| 久久久亚洲欧洲日产国码αv| 亚洲综合二区| 99精品99| 亚洲人成毛片在线播放| 精品盗摄一区二区三区| 国产视频一区二区三区在线观看| 欧美日韩在线三区| 欧美激情视频一区二区三区免费| 久久久综合精品| 久久久久成人精品| 亚洲在线电影| 亚洲视频在线二区| 一本大道久久a久久精二百| 亚洲日本va午夜在线影院| 久久全国免费视频| 久久久久久有精品国产| 欧美一级在线亚洲天堂| 亚洲女人天堂成人av在线| 一个人看的www久久| 亚洲精品一区二区在线观看| 91久久精品国产91久久| 亚洲激情啪啪| 亚洲精品视频二区| 一本久道久久综合狠狠爱| 亚洲国产一二三| 在线精品在线| 亚洲国产成人精品女人久久久| 国色天香一区二区| 亚洲电影下载| 亚洲每日更新| 亚洲在线播放电影| 午夜欧美精品| 久久久精品一区二区三区| 欧美一级片一区| 久久久999成人| 蜜月aⅴ免费一区二区三区| 免费在线看一区| 亚洲电影在线播放| 亚洲靠逼com| 一区二区三区久久网| 亚洲女同同性videoxma| 欧美一区二区三区四区高清| 久久精品女人的天堂av| 嫩草影视亚洲| 欧美日韩视频专区在线播放| 国产精品久久久久秋霞鲁丝 | 在线观看一区欧美| 亚洲精品婷婷| 亚洲欧美日韩国产综合在线| 久久国产福利国产秒拍| 老司机精品视频网站| 亚洲国产激情| 99精品国产热久久91蜜凸| 亚洲男人的天堂在线| 久久综合色影院| 欧美视频中文字幕在线| 国产一区激情| 日韩一级不卡| 久久精品成人一区二区三区| 亚洲大片av| 亚洲素人在线| 美女黄毛**国产精品啪啪| 欧美日韩一区二区三区免费| 国产一区二区三区不卡在线观看 | 欧美成人免费全部| 亚洲六月丁香色婷婷综合久久| 亚洲综合第一页| 免费成人黄色片| 国产精品羞羞答答xxdd| 亚洲成人影音| 午夜亚洲视频| 亚洲国产精品成人综合| 亚洲永久字幕| 欧美日本亚洲视频| 黄色成人av网站| 亚洲男人的天堂在线aⅴ视频| 久久久久久综合网天天| 99国产精品久久久久久久| 久久婷婷亚洲| 国产视频综合在线| 亚洲少妇自拍| 欧美国产亚洲精品久久久8v| 亚洲影视综合| 欧美午夜剧场| 日韩一级欧洲| 欧美ed2k| 久久久精品国产一区二区三区| 欧美先锋影音| 亚洲日本视频| 蜜桃久久av一区| 欧美在线二区| 国产美女诱惑一区二区| 亚洲线精品一区二区三区八戒| 欧美高清视频一二三区| 欧美在线黄色| 国产一区二区三区最好精华液| 99综合在线| 亚洲国产精品成人| 麻豆精品精华液| 精品av久久707| 久久久视频精品| 欧美亚洲视频在线看网址| 国产精品久久久久久一区二区三区| 亚洲精品永久免费精品| 欧美r片在线| 久久一区二区精品| 精品成人在线| 蜜臀a∨国产成人精品| 久久久www| 很黄很黄激情成人| 久久亚洲二区| 久久久蜜桃精品| 亚洲第一中文字幕在线观看| 狼狼综合久久久久综合网| 久久国产夜色精品鲁鲁99| 国产日产亚洲精品系列| 久久精品国产第一区二区三区最新章节 | 久久亚洲精品一区二区| 性欧美大战久久久久久久免费观看 | 一本色道久久综合亚洲精品婷婷| 欧美日韩1234| 亚洲综合国产激情另类一区| 亚洲天堂av高清| 国产精品视频免费| 性做久久久久久| 性欧美超级视频| 在线看欧美日韩| 亚洲国产精品电影在线观看| 欧美激情视频在线播放| 亚洲视频导航| 亚洲在线成人精品| 黄色在线一区| 欧美高清视频在线播放| 欧美mv日韩mv国产网站app| 亚洲免费电影在线观看| 亚洲天堂久久| 国产午夜精品视频| 欧美成人免费全部观看天天性色| 欧美成人国产va精品日本一级| av不卡在线看| 午夜国产欧美理论在线播放 | 亚洲靠逼com| 中日韩视频在线观看| 国产欧美一区二区色老头| 女仆av观看一区| 欧美精品九九| 欧美一区久久| 欧美电影免费观看| 欧美一级片在线播放| 久久亚洲一区二区三区四区| 亚洲美女黄色片| 午夜精品区一区二区三| 91久久精品久久国产性色也91| 夜夜嗨av一区二区三区网站四季av| 国产午夜精品理论片a级探花| 欧美二区乱c少妇| 国产精品青草久久久久福利99|