sgu209 Areas 計算幾何

2021-09-08 11:22:08 字數 2855 閱讀 6138

意甲冠軍:

給一些直。這架飛機被分成了很多這些線性塊。每個塊的需求面積封閉曲線圖。

分析:

①我們應要求交點22的直線;

②每行上的交點的重排序,藉此來離散一整行(正反兩條邊);

③對於連向乙個點的幾條線段,對它們進行極角排序,相鄰的兩條線段我們給它們之間連一條邊,我們腦補一下應該能夠知道如何能夠保證逆時針連邊;

④找迴圈,利用叉積求面積。ps

.vec

tor的除錯真心不爽…

#include 

#include

#include

#include

#include

#define pb push_back

#include

#define fi first

#define se second

#define mp make_pair

#include

using

namespace

std;

const

int maxn = 100;

const

int maxe = maxn*maxn<<1;

const

double eps = 1e-8;

typedef

double db;

int n;

#define sqr(x) ((x)*(x))

struct pot

inline

double len()

inline

void read()

inline pot unit()

inline

double ang()

};typedef pot vec;

struct line

line(pot p, vec v):p(p), v(v){}

}lines[maxn];

vector

points;

struct edge

inline

void add(int u, int v)

}e;int next[maxe];

bool vis[maxe];

vector

ans;

inline

int dcmp(double x)

inline pot operator + (const vec &a, const vec &b)

inline pot operator - (const vec &a, const vec &b)

inline

double

operator * (const vec &a, const vec &b)

inline

double

operator ^ (const vec &a, const vec &b)

inline pot operator * (const vec &a, double k)

inline pot operator / (const vec &a, double k)

inline

bool

operator

< (const vec &a, const vec &b)

inline

bool

operator == (const vec &a, const vec &b)

inline pot get_line_intersection(const pot &p, const vec &v, const pot &q, const vec &w)

inline

bool parallel(const line &a, const line &b)

inline

int get_pot_id(const pot &p)

inline

bool cmp(db a, db b)

inline

void init()

for(int i = 0; i < n; ++i)

for(int j = i+1; j < n; ++j)

if(!parallel(lines[i], lines[j]))

points.pb(get_line_intersection(lines[i].p, lines[i].v, lines[j].p, lines[j].v));

sort(points.begin(), points.end());

points.erase(unique(points.begin(), points.end()), points.end());

for(int i = 0; i < n; ++i)

sort(nodes.begin(), nodes.end());

nodes.erase(unique(nodes.begin(), nodes.end(), cmp), nodes.end());

for(int j = 1, sz = nodes.size(); j < sz; ++j)

}memset(next, -1, sizeof(next));

for(int i = 0, sz = points.size(); i < sz; ++i)

}inline

void work()

while(!vis[j]);

if(i == j)

area *= 0.5;

if(dcmp(area) > 0)

ans.pb(area); }}

}inline

void print()

int main()

209 單詞規律2020 12 16

給定一種規律 pattern 和乙個字串 str 判斷 str 是否遵循相同的規律。這裡的 遵循 指完全匹配,例如,pattern 裡的每個字母和字串 str 中的每個非空單詞之間存在著雙向連線的對應規律。例項 輸入 pattern abba str dog cat cat dog 輸出 true輸...

SGU223 狀態壓縮

下午花了兩個小時把yali中學 陳丹琦的 基於連通性狀態壓縮的動態規劃問題 啃完,插頭dp還真是個麻煩的東西。相較sgu223算乙個水題了,給定n n的棋盤,擺放m個不相互攻擊的棋子,棋子攻擊範圍為相鄰8個位置。求方案數。dp i j k 第i行,狀態為j,放了k個棋子的方案數,dp i j k s...

解題報告 sgu 102

譯題 給定乙個整數n,尋找有多少個不大於n的數與其互質。互質是指兩個數的最大公約數是1。輸入1個整數n 輸出輸出答案 樣例輸入 9樣例輸出 6額,首先,這個題暴力可做。好像這就是它的通過率如此高的原因。尤拉函式 n p 1 t 1 p 2 t 2 p 3 t 3 p 1 p 2 p 3 為質因數。f...