09 2012 档案
摘要:View Code #include<stdio.h>#include<string.h>#include<algorithm>using namespace std;const int maxn = 20003;struct node{ int v, next, w;}edge[maxn<<1];int tot;int head[maxn];int n;void init(){ tot = 0; memset(head, -1, sizeof(int) * (n+1));}void add(int x, int y){ edge[tot].v
阅读全文
摘要:代码1:View Code #include<stdio.h>#include<string.h>#include<algorithm>using namespace std;#define maxn 1003#define inf 1<<29struct node{ int v, next, w;}edge[maxn<<1];int head[maxn];int tot;int n, m;void init(){ tot = 0; memset(head, -1, sizeof(head));}void add(int x, int
阅读全文
摘要:View Code #include<stdio.h>#include<string.h>#include<algorithm>using namespace std;struct node{ int l, r;}p[303];bool vis[303];int n;bool cmp(node a, node b){ return a.r < b.r || a.r == b.r && a.l > b.l;}int main(){ int i, j, k; int ll, rr; while( ~scanf("%d&quo
阅读全文
摘要:模拟题,每个字母代表一个数字,最多有五个字母,然后搜索一下即可。View Code #include<stdio.h>#include<string.h>#include<map>#include<algorithm>using namespace std;char s1[12], s2[12], s3[12];int a, b, c;int len1, len2, len3;int ans, num;bool vis[12];map<char, int> mm; // 表示映射,int表示 字母char是第几个加入map里面的,从1
阅读全文
摘要:题意:有一个二维(0,0)到(10,10)的区域,一个人从(0,0)开始一次拜访区域内的点,去找一样东西(就在这个区域内),每次他到达一个新的点后,都会有一句话,来告诉你是离那个东西更近了(Hotter),还是更远了(Colder),或者距离不变(Same),然后让你算出,这时那个东西可能处在的位置的区域的面积注意点:1. 这题主要搞清楚半平面要取到的区域,还有中垂线自己YY。小知识: 与直线ax+by+c=0垂直的直线方程为bx-ay+d = 0, 根据这个不用考虑斜率为0或不存在的问题,很方便。2. same以后的值都为0;其它 模板。模板1:View Code #include<s
阅读全文
摘要:另一种模板View Code #include<stdio.h>#include<string.h>#include<algorithm>#include<vector>#include<math.h>using namespace std;#define eps 1e-8#define inf 1<<29struct point { double x, y; bool mark; point(){} point(double xx, double yy) : x(xx), y(yy), mark(1) {}};vecto
阅读全文
摘要:水题,样例是错的,记得要考虑半平面交缩成一点, 水水就过了。View Code #include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>using namespace std;struct point{ double x, y;}p[105], tp[105], pp[105];double a, b, c;int n, m;double r;void getline( point p1, point p2){ a = p2.y - p1.y; b = p1.x
阅读全文
摘要:View Code #include<stdio.h>#include<string.h>#include<algorithm>#include<math.h>using namespace std;#define eps 1e-8#define inf 1<<29struct point{ double x, y;}p[105], tp[105], pp[105];double a, b, c;int n, m;void getline(point p1, point p2){ a = p2.y - p1.y; b = p1.x -
阅读全文
摘要:模板题,没什么好说的。View Code #include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>using namespace std;#define eps 1e-8struct point{ double x, y;}p[1505], tmp[1505], q[1505];double a, b, c;void get_line(point p1, point p2){ a = p2.y - p1.y; b = p1.x - p2.x; c = p2.x *
阅读全文
摘要:POJ 3335 Rotating Scoreboard注意:题目给出的点集默认是顺时针的。View Code #include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>using namespace std;struct point{ double x, y;}p[105], tmp[105], q[105];double a, b, c;void get_line(point p1, point p2){ a = p2.y - p1.y; b = p1.x -
阅读全文
摘要:Pick公式:平面上以格子点为顶点的简单多边形,如果边上的点数为on,内部的点数为in,则它的面积为area=on/2+in-1利用gcd求每个边上的点数。View Code #include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>#include<stdlib.h>using namespace std;struct point{ int x, y;}p[5];int gcd(int a, int b){ return b == 0 ? a : gc
阅读全文
摘要:注意这题 多边形有凹有凸。水题。不解释View Code #include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>#include<stdlib.h>#define lld __int64using namespace std;struct point{ lld x, y;}p[1000003];lld cal(int n, point *p){ int i; lld s = 0; p[n] = p[0]; for(i = 0; i < n; i
阅读全文
摘要:一定要注意 总的点数 n<= 2 时 graham不适用。还要注意 graham找到凸包后 注意 top <=2 时面积为0。View Code #include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>using namespace std;struct point{ double x, y;}p[10003];double det(double x1, double y1, double x2, double y2){ return x1 * y2
阅读全文
摘要:题意:给出一个去掉几个点后的凸包,判断剩下的几个点组成的新凸包是不是原来的那个凸包。分析:只要 新凸包的每条边上有3个或3个以上的点时,凸包就是原来那个凸包,否则凸包不是原来那个凸包。 很好理解的,不是很难想到。View Code #include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>using namespace std;#define eps 1e-8struct point{ int x, y;}p[1003];int det(int x1, int y1
阅读全文
摘要:RT,注意考虑凸包点数小于3的情况View Code #include<stdio.h>#include<string.h>#include<algorithm>#include<math.h>using namespace std;#define eps 1e-8#define inf 1<<29struct point{ int x, y; point(){} point(int xx, int yy) : x(xx), y(yy){}};struct data{ int x, y, v, l;}d[16];int det(int
阅读全文
摘要:题意:给你一些点,这些点里面一定有(0,0)原点,并且没有第二象限中的点,这些点是一个凸包,让你按极角序输出这些点。就排序,比较水,没凸包真扫兴View Code #include<stdio.h>#include<string.h>#include<algorithm>#include<math.h>using namespace std;#define eps 1e-8#define inf 1<<29struct point{ int x, y;}p[52];int det(int x1, int y1, int x2, int
阅读全文
摘要:题意:国王想建一个周长最短的城墙,使墙的任意一点到城墙的距离都 > l。求这面墙的周长。不难发现题目要求的就是 凸包的周长+半径为l圆的周长。不清楚Graham-scan算法的两种排序概念的可以去看看lrj的黑书,黑书介绍了两种排序方法来实现Graham-scan算法。1. 极角序 (看了lrj的黑书就知道这个排序不能解决某些共线问题,有一定的缺陷,但这题反映不出它的缺陷)View Code #include<stdio.h>#include<string.h>#include<algorithm>#include<math.h>using
阅读全文

浙公网安备 33010602011771号