- 博客(11)
- 收藏
- 关注
原创 POJ2352
把横坐标看成区间,已知输入是先对y排序再对x排序,每次加一个点先查询该点x坐标的左端有多少点,再更新点。#include #include #include using namespace std;int sum[200000];struct node { int x,y;} p[20000];void push_up(int root) { sum[root]=sum[r
2016-11-21 11:11:58 212
原创 POJ1061
扩展欧几里得求特解#include//please declare parameters here.long long k,t,d;//please declare functions here.void extend_gcd(long long a,long long b){ if(b==0) { k=1; t=0; d=a; } else { ext
2016-11-21 11:10:13 211
原创 HDU1285
注意重边#include#includeusing namespace std;const int num=505;int map[num][num],in[num],n,m,ans[num],cnt;void topo(){ int i,j,t; for(i=0;i<n;i++) { for(j=1;j<=n;j++) {
2016-11-21 11:08:31 310
原创 HDU1232
并查集#includeconst int MAXN=1010;int F[MAXN];int find(int t){ if(F[t]==-1) return t; return F[t]=find(F[t]);} void bing(int a,int b){ int t1=find(a); int t2=find(b); if(t
2016-11-21 11:00:21 180
原创 HDU2203
KMP#include#include#include#include#include#include#include#include#include#define INF 99999999using namespace std;const int MAX=100000+10;char s1[MAX],s2[MAX];int next[MAX];void get
2016-11-21 10:58:54 316
原创 HDU2594
KMP#include#include#include#include#include#include#include#include#include#define INF 99999999using namespace std;const int MAX=50000+10;char s1[MAX*2],s2[MAX];int next[MAX*2];void
2016-11-21 10:56:22 258
原创 51Nod1459
dijkstra打印路径,最短路#include using namespace std;int n,m,Start,End;const int maxn = 510;const int INF = 0x3f3f3f3f;struct node{ int to,next,w;}edge[maxn*maxn+10];int tot, head[maxn];void ini
2016-11-21 10:54:43 229
原创 HDU1372
马走日字,bfs求最小步数#include #include #includeusing namespace std;int s1,s2,e1,e2;int tu[8][8];int xx[8] = {1, 2, 1, 2, -1, -2, -1, -2};//x坐标变化int yy[8] = {2, 1, -2, -1, 2, 1, -2, -1};//y坐标变化int bf
2016-11-21 10:52:22 249
原创 HDU1548
BFS#include #include #include #include using namespace std; int N, A, B; int a[205]; bool map[205], flag; struct node { int x, step; }n1, n2, m; int main()
2016-11-21 10:49:18 300
原创 HDU1010
题意:输入一个n*m的迷宫,和一个T:可以在迷宫中生存的最大时间。S为起点,D为终点。并且,每个格子只能踩一次,且只能维持一秒,然后该块地板就会塌陷。所以你必须每秒走一步,且到D点时,所用时间为T。(奇偶剪枝优化)#includeusing namespace std;int sx,sy,ex,ey;int n,m;char map[10][10]; int flag,
2016-11-21 10:46:04 212
原创 POJ1979
题意:给你一个row*col的矩阵,上面的'#'代表你不能走的地方,'.'表示你能走的地方,'@'表示你的起点,问你最多能走多少格。思路:dfs的简单变形。只要记录下搜过的个数,便是他能走的格数。#includeusing namespace std;const int Max= 22; int row, col, ans;bool map[Max][Max], vi
2016-11-21 10:44:28 167
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人