日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

HNOI2019fish

發布時間:2025/3/14 编程问答 17 豆豆
生活随笔 收集整理的這篇文章主要介紹了 HNOI2019fish 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

\({\rm fish}\)

20分:

六個for,點積判銳角鈍角。

#include <vector> #include <queue> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm>#define LL long long #define uint unsigned int #define debug(...) fprintf(stderr, __VA_ARGS__) #define GO debug("GO\n") #define rep(i, a, b) for (register uint (i) = (a); (i) <= (b); ++ (i)) #define dep(i, a, b) for (register uint (i) = (a); (i) >= (b); -- (i))namespace io {const char endl = '\n';template<typename T> inline void chkmin(T &a, T b) { a > b ? a = b : 0; }template<typename T> inline void chkmax(T &a, T b) { a < b ? a = b : 0; }struct Stream {template<class T> Stream operator>> (T &x) { register int f = 1; register char c;while (!isdigit(c = getchar())) if (c == '-') f = -1;while (x = (x << 1) + (x << 3) + (c ^ 48), isdigit(c = getchar()));return x *= f, *this;}Stream operator>> (char *str) { return scanf("%s", str), *this; }template<class T> Stream operator<< (T x) {static char out[35]; static uint top = 0; if (x < 0) x = -x, out[++top] = '-';while (out[++top] = x % 10 ^ 48, x /= 10, x); while (putchar(out[top--]), top);return *this;}Stream operator<< (char *str) { return printf("%s", str), *this; }Stream operator<< (char ch) { return putchar(ch), *this; }} cin, cout; }const int N = 20;struct Vector {int x, y;Vector() {}Vector(int _x, int _y) { x = _x, y = _y; }Vector operator-(Vector B) { return Vector(x - B.x, y - B.y); }Vector operator+(Vector B) { return Vector(x + B.x, y - B.y); }int operator*(Vector B) { return x * B.x + y * B.y; }int len2() { return x * x + y * y; } } P[N];int main() { #ifndef ONLINE_JUDGEfreopen("xhc.in", "r", stdin);freopen("xhc.out", "w", stdout); #endifregister int n, ans = 0;std::cin >> n;rep(i, 1, n) std::cin >> P[i].x >> P[i].y;rep(A, 1, n) rep(B, 1, n) rep(C, 1, n) rep(D, 1, n) rep(E, 1, n) rep(F, 1, n) {if (A == B || A == C || A == D || A == E || A == F) continue;if (B == C || B == D || B == E || D == F) continue;if (C == D || C == E || C == F) continue;if (D == E || D == F) continue;if (E == F) continue;if ((P[B] - P[A]) * (P[D] - P[A]) > 0 and (P[D] - P[A]) * (P[C] - P[A]) > 0 and(P[B] - P[D]) * (P[A] - P[D]) > 0 and (P[C] - P[D]) * (P[A] - P[D]) > 0 and (P[A] - P[D]) * (P[E] - P[D]) < 0 and(P[A] - P[D]) * (P[F] - P[D]) < 0 and(P[A] - P[B]).len2() == (P[A] - P[C]).len2() and(P[B] - P[D]).len2 ()== (P[D] - P[C]).len2() and(P[E] - P[D]).len2() == (P[D] - P[F]).len2()) {ans ++;}}io::cout << ans << io::endl;return 0; }

40分:

對著題面中的圖講,

第一部分:

枚舉 (A, D) 然后再枚舉 P (形如E,F的點)將所有 PD 滿足 角ADP 為鈍角的 PD 的長扔進一個 vector,

然后 sort,用 f[A][D] 表示 AD 為脊柱,的尾巴數量,由于 sort 了,很好計算出來。

再用 map 實現一個 AD斜率->vector 的映射,vector存斜率為這個的(A, D)。

第二部分:

枚舉 (B, C) ,求出 AD斜率 (垂直) ,到 對應的斜率的vector (map映射)中尋找符合題意的 (A, D) ,然后 Ans 加上 f[A][D].

根據題意,最后 Ans *= 4.

#include <vector> #include <map> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm>#define LL long long #define uint unsigned int #define debug(...) fprintf(stderr, __VA_ARGS__) #define GO debug("GO\n") #define rep(i, a, b) for (register uint i = a, i##end = b; i <= i##end; ++ i) #define dep(i, a, b) for (register uint i = a, i##end = b; i >= i##end; -- i)namespace io {const char endl = '\n';template<typename T> inline void chkmin(T &a, T b) { a > b ? a = b : 0; }template<typename T> inline void chkmax(T &a, T b) { a < b ? a = b : 0; }struct Stream {template<class T> Stream operator>> (T &x) { x = 0; register int f = 1; register char c;while (!isdigit(c = getchar())) if (c == '-') f = -1;while (x = (x << 1) + (x << 3) + (c ^ 48), isdigit(c = getchar()));return x *= f, *this;}Stream operator>> (char *str) { return scanf("%s", str), *this; }template<class T> Stream operator<< (T x) {static char out[35]; static uint top = 0; if (x < 0) x = -x, out[++top] = '-';while (out[++top] = x % 10 ^ 48, x /= 10, x); while (putchar(out[top--]), top);return *this;}Stream operator<< (char *str) { return printf("%s", str), *this; }Stream operator<< (char ch) { return putchar(ch), *this; }} cin, cout; }const int N = 400 + 10;struct vector {int x, y;vector(int x = 0, int y = 0) : x(x), y(y) {}vector operator-(const vector B) { return vector(x - B.x, y - B.y); }LL operator*(const vector B) { return 1ll * x * B.x + 1ll * y * B.y; }LL len2() { return 1ll * x * x + 1ll * y * y; } } p[N];const uint INF = 0x3f3f3f3f; int n; LL f[N][N]; std::vector<int> buc; std::map<std::pair<int, int>, std::vector<std::pair<int, int> > > Map;int main() { #ifndef ONLINE_JUDGEfreopen("fish.in", "r", stdin);freopen("fish.out", "w", stdout); #endifio::cin >> n;rep(i, 1, n) io::cin >> p[i].x >> p[i].y;rep(A, 1, n) {rep(D, 1, n) if (A != D) {buc.clear();rep(P, 1, n) if (P != A and P != D) {if ((p[P] - p[D]) * (p[A] - p[D]) < 0) {buc.push_back((p[P] - p[D]).len2());}}std::sort(buc.begin(), buc.end());uint i = 0;while (i < buc.size()) {uint j = i;while(i < buc.size() - 1 and buc[i] == buc[i + 1]) {i++;}f[A][D] += 1ll * (i - j + 1) * (i - j) / 2;i++;}int up = p[D].y - p[A].y, down = p[D].x - p[A].x, gcd;gcd = std::__gcd(abs(up), abs(down));if (gcd) Map[std::make_pair(up / gcd, down / gcd)].push_back(std::make_pair(A, D));else if (up == 0)Map[std::make_pair(0, INF)].push_back(std::make_pair(A, D));else Map[std::make_pair(INF, 0)].push_back(std::make_pair(A, D));}}LL Ans = 0;rep(B, 1, n) {rep(C, 1, n) {int up = p[B].y - p[C].y, down = p[B].x - p[C].x, gcd;gcd = std::__gcd(abs(up), abs(down));std::pair<int, int> Kad;if (gcd) Kad = std::make_pair(-down / gcd, up / gcd);else if (up == 0) Kad = std::make_pair(INF, 0);else Kad = std::make_pair(0, INF);for (auto i : Map[Kad]) {register uint A = i.first, D = i.second;if ((p[B] - p[A]).len2() == (p[C] - p[A]).len2() and (p[B] - p[D]).len2() == (p[C] - p[D]).len2() and(p[B] - p[A]) * (p[D] - p[A]) > 0 and(p[C] - p[A]) * (p[D] - p[A]) > 0 and(p[B] - p[D]) * (p[A] - p[D]) > 0 and (p[C] - p[D]) * (p[A] - p[D]) > 0) {Ans += f[A][D]; // io::cout << A << ' ' << B << ' ' << C << ' ' << D << io::endl; // io::cout << f[A][D] << io::endl;}}}}std::cout << Ans * 4 << io::endl; }

100分

40分復雜度的瓶頸在于計算以AD為脊柱的尾巴的個數,由于我們發現合法的尾巴只可能在垂直AD的直線的右側,所以考慮先枚舉D,按極角排序,再枚舉A,讓A圍著D逆時針轉,同時維護合法平面內的尾巴數量,維護的方式與莫隊的方法類似。

然后同樣枚舉AD,為了為了快速求出合法的BC的數量,需要事先處理出任意兩點中垂線的解析式,那么魚的脊柱肯定在BC的中垂線上,所以枚舉AD時,通過對AD這條直線所包含的點二分查找就可以知道有多少對BC,再乘以尾巴的數量即可,這里的實現比較復雜,用map映射直線所代表的vector,vector存BC的中點,具體難以描述, 細節就是特判沒有斜率的情況。

#include <vector> #include <map> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm>#define LL long long #define uint unsigned int #define debug(...) fprintf(stderr, __VA_ARGS__) #define GO debug("GO\n") #define rep(i, a, b) for (register uint i = a, i##end = b; i <= i##end; ++ i) #define dep(i, a, b) for (register uint i = a, i##end = b; i >= i##end; -- i) #define int LLnamespace io {const char endl = '\n';template<typename T> inline void chkmin(T &a, T b) { a > b ? a = b : 0; }template<typename T> inline void chkmax(T &a, T b) { a < b ? a = b : 0; }struct Stream {template<class T> Stream operator>> (T &x) { x = 0; register int f = 1; register char c;while (!isdigit(c = getchar())) if (c == '-') f = -1;while (x = (x << 1) + (x << 3) + (c ^ 48), isdigit(c = getchar()));return x *= f, *this;}Stream operator>> (char *str) { return scanf("%s", str), *this; }template<class T> Stream operator<< (T x) {static char out[35]; static uint top = 0; if (x < 0) x = -x, out[++top] = '-';while (out[++top] = x % 10 ^ 48, x /= 10, x); while (putchar(out[top--]), top);return *this;}Stream operator<< (char *str) { return printf("%s", str), *this; }Stream operator<< (char ch) { return putchar(ch), *this; }} cin, cout; }const long double PI = acos(-1), eps = 1e-10; const int N = 1e3 + 10;struct vector {int x, y, id;long double atan;vector(int x = 0, int y = 0) : x(x), y(y) {}vector operator-(const vector B) { return vector(x - B.x, y - B.y); }LL operator*(const vector B) { return 1ll * x * B.x + 1ll * y * B.y; }LL len2() { return 1ll * x * x + 1ll * y * y; } } p[N], vec[N * 2];struct frac {LL u, d;void simp() { LL gcd = std::__gcd(u, d); if (gcd) u /= gcd, d /= gcd; if (d < 0) d = -d, u = -u; }bool operator< (const frac& B) const { return u < B.u || (u == B.u and d < B.d); }bool operator== (const frac& B) const { return (u == B.u and d == B.d); } };struct line {frac k, b;bool operator<(const line& B) const { if(k == B.k) return b < B.b; else return k < B.k; } } ;bool cmp(const vector &a, const vector &b) { return a.atan < b.atan; }const uint INF = 0x3f3f3f3f;int n, cnt, sum; LL f[N][N]; std::map<line, int> Map; std::map<LL, int> Cnt; std::vector<int> buc[N * N];void add(int x) {sum += Cnt[vec[x].len2()]++; } void del(int x) {sum -= --Cnt[vec[x].len2()]; }signed main() { #ifndef ONLINE_JUDGEfreopen("fish100.in", "r", stdin);freopen("fish100.out", "w", stdout); #endifio::cin >> n;rep(i, 1, n) io::cin >> p[i].x >> p[i].y;rep(i, 1, n) {rep(j, i + 1, n) {if (p[i].y == p[j].y) {if ((p[i].x + p[j].x) & 1) continue;line L;L.k = (frac) { INF, 0 }, L.b = (frac) { (p[i].x + p[j].x) / 2, 1 };if (Map.find(L) == Map.end()) Map[L] = ++cnt;buc[Map[L]].push_back(p[i].y * 2);} else {line L;L.k = (frac) { p[i].x - p[j].x, p[j].y - p[i].y }; L.k.simp();L.b = (frac) { 1ll * (p[i].y + p[j].y) * (p[i].y - p[j].y) + 1ll * (p[i].x + p[j].x) * (p[i].x - p[j].x), 2ll * (p[i].y - p[j].y) }; L.b.simp();if (Map.find(L) == Map.end()) Map[L] = ++cnt;buc[Map[L]].push_back(p[i].x == p[j].x ? p[i].x * 2 : p[i].y + p[j].y);}}}rep(i, 1, cnt) sort(buc[i].begin(), buc[i].end());rep(i, 1, n) {int tot = 0;rep(j, 1, n) {if (i != j) {vec[++tot] = p[j] - p[i];vec[tot].atan = atan2(vec[tot].y, vec[tot].x);vec[tot].id = j;}}std::sort(vec + 1, vec + 1 + tot, cmp);rep(i, 1, tot) vec[i + tot] = vec[i], vec[i + tot].atan += PI * 2;Cnt.clear();sum = 0;for (int j = 1, begin = 0, end = 0; j <= tot; ++ j) { // (, ]while (begin <= tot * 2 and vec[begin + 1].atan < vec[j].atan + 0.5 * PI + eps) begin++, del(begin);while (end <= tot * 2 and vec[end + 1].atan + eps < vec[j].atan + 1.5 * PI) end++, add(end);f[vec[j].id][i] = sum;}}LL ans = 0;rep(i, 1, n) {rep(j, i + 1, n) {int a, b;if (p[i].y == p[j].y) a = std::min(p[i].x, p[j].x), b = std::max(p[j].x, p[i].x);else a = std::min(p[i].y, p[j].y), b = std::max(p[i].y, p[j].y);line L;if (p[i].x == p[j].x) {L.k = (frac) { INF, 0 };L.b = (frac) { p[i].x, 1 };} else {L.k = (frac) { p[i].y - p[j].y, p[i].x - p[j].x }; L.k.simp();L.b = (frac) { 1ll * p[i].y * (p[i].x - p[j].x) + p[i].x * (p[j].y - p[i].y), p[i].x - p[j].x }; L.b.simp();}if (Map.find(L) == Map.end()) continue;int c = Map[L];ans += 1ll * (std::upper_bound(buc[c].begin(), buc[c].end(), b * 2 - 1) - std::upper_bound(buc[c].begin(), buc[c].end(), a * 2)) * (f[i][j] + f[j][i]);}}io::cout << ans * 4 << io::endl;return 0; }

轉載于:https://www.cnblogs.com/cnyali-Tea/p/10846414.html

總結

以上是生活随笔為你收集整理的HNOI2019fish的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 欧美精品在线免费 | 91精品国产综合久久福利 | 国产系列精品av | 亚洲激情视频小说 | 欧洲性开放大片 | 日韩电影一区二区 | 黄色片免费在线观看 | 肉丝超薄少妇一区二区三区 | 色老头在线观看 | 国产视频xxx| 综合网婷婷 | 日韩激情片 | 黑人精品欧美一区二区蜜桃 | 男生草女生视频 | 国产精品影片 | 伊人久久国产 | 夜夜操夜夜爱 | 精品免费一区 | 嫩草天堂| 亚洲麻豆精品 | 91精品国产欧美一区二区 | 婷婷资源网 | 欧美一区二区高清视频 | 日韩在观看线 | 精品二三区 | 综合国产精品 | 无人在线观看的免费高清视频 | 黄色一级一级 | 草女人视频 | 国产又粗又猛又大爽 | 爽爽影院免费观看 | 欧美日韩一区在线 | www.日韩av | 日本欧美久久久 | 国产精品国产三级国产专区51区 | 日韩欧美精品在线播放 | av网站观看| 国模私拍一区二区 | 日韩毛片无码永久免费看 | av中文字幕免费 | 91爱爱.com | 亚洲国产天堂av | 欧美色精品在线 | 日本www免费 | 亚洲免费黄色网 | 欧美福利网站 | 亚洲高清欧美 | 禁久久精品乱码 | 黄色免费av | 日本吃奶摸下激烈网站动漫 | 亚洲最大综合网 | 一区二区av | 337p嫩模大胆色肉噜噜噜 | 尤物视频最新网址 | 国产自产精品 | 亚洲天堂网在线视频 | 欧美一级二级视频 | 夜夜爽夜夜叫夜夜高潮漏水 | 色花堂在线 | 欧美xxxx×黑人性爽 | 久久亚洲无码视频 | 日本少妇xxxx软件 | 黄页网站免费在线观看 | 中文字幕在线观看的网站 | 潮见百合子 | 黄色片小视频 | 日本在线国产 | 少女与动物高清版在线观看 | 国产精品久久久久久久久久免费看 | 国产精品美女久久久久av超清 | 久久久久久久久久久久久av | free欧美性69护士呻吟 | www.激情| 久色视频在线 | 日韩中文字幕国产 | 日韩综合第一页 | 亚州一级 | 在线观看免费黄视频 | 亚洲 另类 春色 国产 | 国产精品视频免费看 | 男人的天堂视频网站 | 日韩一区二区a片免费观看 伊人网综合在线 | 2021狠狠干 | 一级视频在线免费观看 | 久久a级片 | 欧美午夜精品理论片 | 免费麻豆视频 | 国产伦精品视频一区二区三区 | 欧美日韩在线影院 | 伊人久久精品一区二区三区 | 欧美色综合 | 欧美天天影院 | 日韩国产精品久久 | 日日噜噜噜噜久久久精品毛片 | yy6080久久 | 在线免费观看日韩 | 成人免费一区 | 色图18p| 日本三级一区二区 |