- 博客(188)
- 资源 (4)
- 收藏
- 关注
原创 LeetCode 394.字符串解码
题目使用编译原理的 LL(1)文法EBNF范式lexp -> id | number [lexp-seq] lexp-seqlexp-seq -> lexp{lexp}Code:class Solution {public: int token=0; string str; inline bool match(char expect){ return str[token]==expect?++token,true:false;
2021-05-04 13:26:28
130
原创 POJ-3074 Dancing Links精确覆盖
题目行(所有情况)81个格子 * 9个数字=9^3列(限制条件)1.每个格子放一个数-812.行限制-9行 * 9个数字3.列限制-9列 * 9个数字4.小宫格限制-9个小宫格 * 9个数字把限制条件插入,dancing…剪枝:先选择数字多的列#include<stdio.h>#include<string.h>using namespace std...
2020-03-21 21:57:48
172
原创 UVA-1395 最小瓶颈生成树
problem求min(maxval-minval)maxval,minval 生成树边的最大最小值sort边集,枚举最小值因为最小生成树同时也是最小瓶颈生成树每次做一遍kruskal更新答案即可code:#include<bits/stdc++.h>using namespace std;typedef long long ll;const int N=1e5+7...
2020-01-28 17:30:54
219
原创 P1144 最短路计数
ProblemCode:#include<bits/stdc++.h>using namespace std;typedef long long ll;const int N=1e6+7;const int mod=1e5+3;int n,m;int d[N],cnt[N];vector<int>e[N];void dijkstra(){ memset...
2020-01-26 11:45:09
136
原创 POJ-2104 主席树板子
DescriptionYou are working for Macrohard company in data structures department. After failing your previous task about key insertion you were asked to write a new data structure that would be able to...
2020-01-13 23:27:21
168
原创 SPOJ-LCS 后缀自动机
题目求字符串s,p的lcs将s加入sam中遍历p,当前字符u初始结点v=1,长度len=0;如果该结点有u的出边,匹配,++len否则通过fa回跳到能匹配的位置。如果一个也不能匹配,v=1,len=0板子#include<iostream>#include<string.h>#include<stdio.h>#include<mat...
2020-01-11 22:40:25
187
原创 POJ-2417 Baby-Step Giant-Step
DescriptionGiven a prime P, 2 <= P < 2 ^ 31, an integer B, 2 <= B < P, and an integer N, 1 <= N < P, compute the discrete logarithm of N, base B, modulo P. That is, find an integer ...
2020-01-10 23:45:54
170
原创 P2261 [CQOI2007]余数求和 --- 整除分块
题目a%b = a - b * ⌊a / b⌋O(√n)求 ∑ ⌊n / i⌋求 ∑ i*⌊n / i⌋,只用多乘个 (l+r)/2#include<bits/stdc++.h>using namespace std;typedef long long ll;int main(){ ll n,k; cin>>n>>k; ll ans=n*k;...
2020-01-10 21:20:12
111
原创 2019 CCPC-ICPC 总结
赛区题数获奖情况ccpc厦门3Cuicpc南京4Cuicpc南昌4Ag本来我(大二)是没机会去区域赛的,因为各种原因,主力队2q1我就以负责计算几何方面(一个月速成)光速进队。有一说一,是真的lucky ^ O ^1.厦门话说这还是我第一次出省+第一次做高铁+第一次住酒店师兄一路叫我不要紧张-但跟两dalao在一起,怎么可能不紧张...
2019-11-11 21:17:29
898
2
原创 cf-1142c 求上凸包
题目#include<iostream>#include<string.h>#include<math.h>#include<stdio.h>#include<algorithm>#include<vector>using namespace std;typedef long long ll;const in...
2019-10-25 13:21:16
110
原创 POJ-2002 hash_map
DescriptionA square is a 4-sided polygon whose sides have equal length and adjacent sides form 90-degree angles. It is also a polygon such that rotating about its centre by 90 degrees gives the same ...
2019-10-13 10:55:54
92
原创 POJ-2600 模拟退火
DescriptionThere is a polygon A1A2…An (the vertices Ai are numbered in the clockwise order). On each side AiAi+1 an isosceles triangle AiMiAi+1 is built on the outer side of the polygon, and angle Ai...
2019-10-12 19:40:32
148
原创 POJ-1118 极角排序 尺取
Description“How am I ever going to solve this problem?” said the pilot.Indeed, the pilot was not facing an easy task. She had to drop packages at specific points scattered in a dangerous area. Furth...
2019-10-12 12:03:05
95
原创 HDU-3400 三分套三分
Problem DescriptionIn a two-dimensional plane there are two line belts, there are two segments AB and CD, lxhgww’s speed on AB is P and on CD is Q, he can move with the speed R on other area on the p...
2019-10-07 23:18:29
127
原创 cf-552D 组合数
D. Vanya and Trianglestime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputVanya got bored and he painted n distinct points on the plane. After th...
2019-10-03 19:32:28
102
原创 cf-650A unordered_map
A. Watchmentime limit per test 3 secondsmemory limit per test 256 megabytesinputstandard inputoutputstandard outputWatchmen are in a danger and Doctor Manhattan together with his friend Daniel Dr...
2019-10-02 16:55:35
139
原创 HDU-4449 三维凸包 平面投影 三维坐标转二维坐标 二维凸包
Problem DescriptionYou are a notable architect.Recently, a company invites you to design their new building for them. It is not an easy task, because they make some strange claims to the new buildin...
2019-09-27 20:40:50
313
原创 HDU-3692 三维几何,二维凸包
Problem DescriptionOn the planet Pandora, huge rocks are floating in the sky. Despite the beautiful scenery, these rocks bring some critical problem: they block the sunshine, and shade on the ground....
2019-09-26 20:01:25
158
原创 HDU-6242 随机rand()
Problem DescriptionAlice is interesting in computation geometry problem recently. She found a interesting problem and solved it easily. Now she will give this problem to you :You are given N distinc...
2019-09-24 21:07:19
135
原创 P4557 [JSOI2018]战争 闵科夫斯基和
题目两个凸包A,B,沿某一方向向量移动B,问是否与A有交两个图形A,B的闵可夫斯基和C={p0+p1|p0∈A,p1∈B}两个凸包的闵科夫斯基和仍然是凸包设p0∈A,p1∈B,方向向量V:满足b+V=a则V=a-b=a+(-b)则V是一个凸包,且是A,B的闵科夫斯基和我们先求A,B的闵科夫斯基和C判断每个向量是否在C中#include<iostream>#inclu...
2019-09-24 15:31:59
134
原创 HDU-6535 计算几何 辛普森积分
Problem DescriptionChika has just learned about solid geometry! She is very interested in the volume of three-dimensional geometric shapes, so she decides to test you.Before that, she is going to te...
2019-09-22 21:01:00
286
原创 cf-1019D 旋转坐标系 二分
D. Large Triangletime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a strange peculiarity: if you connect the cities of Rostov, Taganro...
2019-09-22 19:35:14
246
原创 HDU-3007 最小圆覆盖
Problem DescriptionEach person had do something foolish along with his or her growth.But,when he or she did this that time,they could not predict that this thing is a mistake and they will want this ...
2019-09-19 13:17:06
204
原创 BZOJ-1185 旋转卡壳
Description给定一些点的坐标,要求求能够覆盖所有点的最小面积的矩形,输出所求矩形的面积和四个顶点坐标Input第一行为一个整数n(3<=n<=50000)从第2至第n+1行每行有两个浮点数,表示一个顶点的x和y坐标,不用科学计数法Output第一行为一个浮点数,表示所求矩形的面积(精确到小数点后5位),接下来4行每行表示一个顶点坐标,要求第一行为y坐标最小的顶...
2019-09-16 00:11:51
118
原创 POJ-1755 半平面交解决 判断不等式组有解
#include<iostream>#include<string.h>#include<math.h>#include<stdio.h>#include<algorithm>#include<vector>using namespace std;const int N=1e3+7;const int maxp...
2019-09-16 00:05:55
223
原创 POJ-3525 半平面交,二分答案
DescriptionThe main land of Japan called Honshu is an island surrounded by the sea. In such an island, it is natural to ask a question: “Where is the most distant point from the sea?” The answer to t...
2019-09-13 14:52:08
157
原创 POJ-1265 pick定理
题目给定顶点坐标均是整点(或正方形格点)的简单多边形,皮克定理说明了其面积S和内部格点数目n、边上格点数目s的关系:#include<iostream>#include<string.h>#include<math.h>#include<stdio.h>#include<algorithm>#include<vect...
2019-09-13 00:44:00
139
原创 POJ-1873 凸包
DescriptionOnce upon a time, in a faraway land, there lived a king. This king owned a small collection of rare and valuable trees, which had been gathered by his ancestors on their travels. To protec...
2019-09-12 23:07:47
147
原创 UVA-12304 测试圆相关模板
题目kuangbin模板#include<iostream>#include<string.h>#include<math.h>#include<stdio.h>#include<algorithm>#include<vector>using namespace std;const int N=1e5+7;...
2019-09-11 21:30:11
141
原创 POJ-1039 判断相交计算交点
DescriptionThe GX Light Pipeline Company started to prepare bent pipes for the new transgalactic light pipeline. During the design phase of the new pipe shape the company ran into the problem of dete...
2019-09-10 20:42:41
183
原创 Acwing-241. 楼兰图腾 树状数组求逆序数
题目在完成了分配任务之后,西部314来到了楼兰古城的西部。相传很久以前这片土地上(比楼兰古城还早)生活着两个部落,一个部落崇拜尖刀(‘V’),一个部落崇拜铁锹(‘∧’),他们分别用V和∧的形状来代表各自部落的图腾。西部314在楼兰古城的下面发现了一幅巨大的壁画,壁画上被标记出了N个点,经测量发现这N个点的水平位置和竖直位置是两两不同的。西部314认为这幅壁画所包含的信息与这N个点的相对位置...
2019-09-05 23:47:41
120
原创 POJ-1182 拓展域并查集
Description动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。有人用两种说法对这N个动物所构成的食物链关系进行描述:第一种说法是"1 X Y",表示X和Y是同类。第二种说法是"2 X Y",表示X吃Y。此人对N个动物,用上述两种说法,一句接一...
2019-09-04 22:47:13
149
原创 POJ-1733 边带权并查集
DescriptionNow and then you play the following game with your friend. Your friend writes down a sequence consisting of zeroes and ones. You choose a continuous subsequence (for example the subsequenc...
2019-09-03 23:52:17
248
原创 POJ-1456 贪心并查集
题目优先卖利润大的,并且在过期前尽量晚地卖出建立关于天数的并查集:维护未被占用的最晚的一天对于每个商品,在d天过期,查询d的根节点r在r天卖出,合并r, r-1#include<iostream>#include<vector>#include<stdio.h>#include<algorithm>#include<strin...
2019-08-30 18:53:33
107
原创 POJ-2449 A* bfs
Description“Good man never makes girls wait or breaks an appointment!” said the mandarin duck father. Softly touching his little ducks’ head, he told them a story.“Prince Remmarguts lives in his kin...
2019-08-27 23:58:16
119
原创 POJ-1915 双向bfs
DescriptionBackgroundMr Somurolov, fabulous chess-gamer indeed, asserts that no one else but him can move knights from one position to another so fast. Can you beat him?The ProblemYour task is to ...
2019-08-26 12:40:44
239
原创 POJ-3322 bfs
DescriptionLittle Tom loves playing games. One day he downloads a little computer game called ‘Bloxorz’ which makes him excited. It’s a game about rolling a box to a specific position on a special pl...
2019-08-22 19:47:53
221
原创 ACwing-171. 送礼物 双向搜索
达达帮翰翰给女生送礼物,翰翰一共准备了N个礼物,其中第i个礼物的重量是G[i]。达达的力气很大,他一次可以搬动重量之和不超过W的任意多个物品。达达希望一次搬掉尽量重的一些物品,请你告诉达达在他的力气范围内一次性能搬动的最大重量是多少。输入格式第一行两个整数,分别代表W和N。以后N行,每行一个正整数表示G[i]。输出格式仅一个整数,表示达达在他的力气范围内一次性能搬动的最大重量。数据...
2019-08-20 20:07:06
184
原创 cf-1203E 网络流
E. BoxersThere are n boxers, the weight of the i-th boxer is ai. Each of them can change the weight by no more than 1 before the competition (the weight cannot become equal to zero, that is, it must ...
2019-08-16 16:44:10
175
原创 POJ-2248 迭代加深搜索
DescriptionAn addition chain for n is an integer sequence with the following four properties:a0 = 1am = na0 < a1 < a2 < … < am-1 < amFor each k (1<=k<=m) there exist two (not...
2019-08-15 17:48:03
127
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人