<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      poj 1127 Jack Straws 挑戰程序設計競賽

      地址 http://poj.org/problem?id=1127

      解法
      使用ccw 如果兩個線段相交,對于其中一個線段的兩個點,另外一個線段的兩個點分別是處于逆時針方向和順時針方向的
      也就是說 線段1的ab兩點 分別和線段2的cd兩點計算叉積 應該是正負不同的。
      相交的所有線段算作同一組,這里使用并查集合并。
      代碼如下

       
      #include <iostream>
      #include <cmath>
      
      
      using  namespace std;
      
      const double PI = 2.0 * acos(0.0);
      
      struct vector2 {
      	double x, y;
      	explicit vector2(double x_ = 0, double y_ = 0) :x(x_), y(y_) {}
      	bool operator ==(const vector2& rhs)const {
      		return x == rhs.x && y == rhs.y;
      	}
      
      	bool operator <(const vector2& rhs)const {
      		return x != rhs.x ? x < rhs.x : y < rhs.y;
      	}
      
      	vector2 operator+(const vector2& rhs)const {
      		return vector2(x + rhs.x, y + rhs.y);
      	}
      
      	vector2 operator-(const vector2& rhs)const {
      		return vector2(x - rhs.x, y - rhs.y);
      	}
      	vector2 operator*(double rhs)const {
      		return vector2(x * rhs, y * rhs);
      	}
      
      	double norm()const {
      		return hypot(x, y);
      	}
      
      	//單位向量
      	vector2 normalize()const {
      		return vector2(x / norm(), y / norm());
      	}
      
      	//從x軸的正方向 逆時針旋轉到達當前向量時候的角度
      	double polar()const { return fmod(atan2(y, x) + 2 * PI, 2 * PI); }
      
      	//點積
      	double dot(const vector2& rhs)const {
      		return x * rhs.x + y * rhs.y;
      	}
      
      	//叉積
      	double cross(const vector2& rhs)const {
      		return x * rhs.y - rhs.x * y;
      	}
      	//將當前向量映射到rhs的結果
      	vector2 project(const vector2& rhs)const {
      		vector2 r = rhs.normalize();
      		return r * r.dot(*this);
      	}
      };
      
      double ccw(vector2 a, vector2 b) {
      	return a.cross(b);
      }
      
      double ccw(vector2 p, vector2 a, vector2 b) {
      	return ccw(a - p, b - p);
      }
      
      //返回兩個線段是否相交
      bool segmentIntersects(vector2 a, vector2 b, vector2 c, vector2 d) {
      	double ab = ccw(c, a, b) * ccw(d, a, b);
      	double cd = ccw(a,c, d) * ccw(b,c, d);
      	//兩條線段在同一直線上或端點相互重疊時
      	if (ab == 0 && cd == 0) {
      		if (b < a) swap(a, b);
      		if (d < c) swap(c, d);
      		return !(b < c || d < a);
      	}
      
      	return ab <= 0 && cd <= 0;
      }
      
      struct line {
      	vector2 l, r;
      };
      
      const int N = 15;
      
      struct line LI[N];
      
      int f[N];
      int n;
      
      
      void init() {
      	for (int i = 0; i < N; i++) { f[i] = i; }
      }
      
      int find(int x) {
      	if (f[x] != x) f[x]= find(f[x]);
      
      	return f[x];
      }
      
      void merge(int a,int b) {
      	a = find(a); b = find(b);
      	f[a] = b;
      }
      
      /*
      7
      1 6 3 3
      4 6 4 9
      4 5 6 7
      1 4 3 5
      3 5 5 5
      5 2 6 3
      5 4 7 2
      1 4
      1 6
      3 3
      6 7
      2 3
      1 3
      0 0
      
      2
      0 2 0 0
      0 0 0 1
      1 1
      2 2
      1 2
      0 0
      
      0
      */
      void solve() {
      	//先測試所有線段是否相交 記錄并查集
      	for (int i = 1; i <= n; i++) {
      		for (int j = i + 1; j <= n; j++) {
      			if (find(i) != find(j)) {
      				if (segmentIntersects(LI[i].l, LI[i].r, LI[j].l, LI[j].r)) {
      					merge(i, j);
      				}
      			}
      		}
      	}
      	int a, b;
      	while (cin >> a >> b) {
      		if (a == 0 && b == 0)break;
      		if (find(a) == find(b)) {
      			cout << "CONNECTED" << endl;
      		}
      		else {
      			cout << "NOT CONNECTED" << endl;
      		}
      	}
      
      	return;
      }
      
      int main()
      {
      	while (cin >> n) {
      		if (0 == n) break;
      		init();
      		memset(LI, 0, sizeof LI);
      		for (int i = 1; i <= n; i++) {
      			cin >> LI[i].l.x >> LI[i].l.y >> LI[i].r.x >> LI[i].r.y;
      		}
      		solve();
      	}
      
      	return 0;
      }
      

      我的視頻題解空間

      posted on 2023-02-10 15:53  itdef  閱讀(24)  評論(0)    收藏  舉報

      導航

      主站蜘蛛池模板: 国产美女高潮流白浆视频| 内射一区二区三区四区| 亚洲乱码国产乱码精品精大量| 田东县| 香蕉EEWW99国产精选免费| 国产一区二区三区乱码在线观看 | 91亚洲国产成人精品福利| 五级黄高潮片90分钟视频| 狠狠躁夜夜躁人人爽天天5| 欧美人成精品网站播放| 国产高颜值不卡一区二区 | 国产成人精品永久免费视频| 亚洲国产av区一区二| 中文在线天堂中文在线天堂 | 国产毛片精品av一区二区| 国产精品福利午夜久久香蕉| 欧美熟妇乱子伦XX视频| 亚洲性日韩精品一区二区| 无套内谢少妇一二三四| 国产亚洲精品日韩av在| 无码伊人久久大杳蕉中文无码 | 蜜桃无码一区二区三区| 富顺县| 亚洲熟女乱色综一区二区| 午夜福利免费区在线观看| 欧美极品色午夜在线视频| 亚洲人成网站色www| 中文字幕人妻丝袜美腿乱| 狠狠久久五月综合色和啪| 成人无号精品一区二区三区| 南京市| 亚洲中文字幕在线二页| 亚洲国产免费图区在线视频| 亚洲精品国产精品国在线| 久久香蕉国产线看观看精品yw| 精品视频福利| 亚洲岛国成人免费av| 久久精品国产精品第一区| 精品亚洲无人区一区二区| 阿尔山市| 精品国产成人午夜福利|