![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
我要满满的AC
不积跬步,无以至千里
展开
-
HUD1213 How Many Tables
并查集的简单应用,算法也不用优化原创 2014-07-25 20:55:26 · 387 阅读 · 0 评论 -
POJ1724 ROADS最短路问题
#include#include#includeusing namespace std;struct node{public: int s,d,l,t;}edge[20002];struct node2{public: int f,g,no; bool operator<(const node2 b)const { if(g!=b.g)return g>b.g;原创 2014-07-29 13:49:03 · 342 阅读 · 0 评论 -
POJ1201 Intervals
#include#includeint a[50001],b[50001],c[50001],f[50001];int n,xiao,da;void bellman(){ int flag=1,i; while(flag) { flag=0; for(i=0;i<n;i++) if(f[a[i]]>f[b[i]]-c[i]) { f[a[i]]=f[b[原创 2014-07-29 09:19:15 · 321 阅读 · 0 评论 -
POJ2503 Babelfish字典树
字典树小试#include#includechar s[25],a[11],b[11];#define maxn 200001int ch[maxn][26];char save[maxn][11];int tp;void insert(char *x,int site){ if(*x) { if(!ch[site][*x-'a']) ch[site][*x-'a原创 2014-08-05 13:09:50 · 384 阅读 · 0 评论 -
POJ3332 Parsing Real Numbers DFA
这题本来可能一次性就AC掉的,可惜第二个减kgn原创 2014-08-04 17:01:07 · 607 阅读 · 0 评论 -
COJ1025 Chocolate Auction线段树
区间sum[rt]表示【l,r】区间有多多少个数被标记,setv[rt]为懒惰标记,表示原创 2014-08-04 23:02:16 · 421 阅读 · 0 评论 -
hdu1166 敌兵布阵 线段树
#include#includeint sum[200000],n;void build(int rt,int x,int y,int i,int count){ if(x==y)sum[rt]+=count; else { int mid=(x+y)>>1; if(i<=mid) build(rt*2,x,mid,i,count); else build(原创 2014-07-31 10:25:01 · 349 阅读 · 0 评论 -
HDU1394 Minimum Inversion Number线段树
用线段树表示区间[l,r]中出现已经出现的数字个数。如原创 2014-07-31 13:50:02 · 283 阅读 · 0 评论 -
POJ2528 Mayor's posters线段树
刚开始不知道要离散化这些原创 2014-07-31 17:08:58 · 322 阅读 · 0 评论 -
COJ1333 Funny Car Racing最短路问题
#include#include#include#includeusing namespace std;typedef pair pii;struct node{public: int u,v,t,a,b,sum;}edge[50001];priority_queue,greater >p;int n,m,s,t,first[301],next[50001],ans,w原创 2014-07-29 15:40:08 · 629 阅读 · 0 评论 -
POJ2406Power Strings KMP算法
#include#includechar s[1000001];int next[1000001];int main(){ for(;;) { scanf("%s",s); if(s[0]=='.')break; next[0]=-1; int i=0,k=-1,len=strlen(s); while(i<len) { if(k==-1||s[i]==原创 2014-08-01 20:59:20 · 406 阅读 · 0 评论 -
SPOJ7299. Multiples of 3
#include#includeint n,m,setv[4000000][4],ans;void pushup(int rt){ int lt=rt<<1; int t=(rt<<1)|1; setv[rt][1]=setv[lt][1]+setv[t][1]; setv[rt][2]=setv[lt][2]+setv[t][2]; setv[rt][0]=setv[lt]原创 2014-08-02 16:46:20 · 616 阅读 · 0 评论 -
HDU1272 小希的迷宫
感觉略坑,刚开始是爆栈的,后来改成非递归形式才AC了。原创 2014-07-25 22:08:33 · 377 阅读 · 0 评论 -
codeforces16E.fish
#include#include#define maxn 1<<18double dp[maxn],p[18][18];int main(){ int n,i,j,k,s; scanf("%d",&n); for(i=0;i<n;i++) for(j=0;j<n;j++) scanf("%lf",&p[i][j]); dp[(1<<n)-1]=1; for(s=(1=原创 2014-07-28 14:35:57 · 371 阅读 · 0 评论 -
POJ3461 Oulipo KMP
一道简单的KMP题,却让我发现自己的不少问题。#include#include#define N 1000005char w[N],t[N];int next[1000005];int main(){ int T,i,j,k,ans; scanf("%d",&T); while(T--) { scanf("%s%s",w,t); int len1=strlen(w)原创 2014-08-01 16:30:39 · 328 阅读 · 0 评论 -
POJ2752 Seek the Name, Seek the Fame KMP算法
今天再做KMP时做得不是很好,因此就对此展开了训练。原创 2014-08-01 21:00:19 · 274 阅读 · 0 评论 -
codeforces 237C.Primes on Interval
C. Primes on Intervaltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou've decided to carry out a survey原创 2014-07-27 16:14:10 · 571 阅读 · 0 评论 -
POJ2458 Highways
#include#includeint n,map[500][500],ans,low[500],vis[500];;;void prim(){ int cur,minn,i,k,j; ans=-1<<30; memset(vis,0,sizeof(vis)); cur=0;low[0]=0;vis[0]=1; for(i=1;i<n;i++) low[i]=map[0][i原创 2014-07-26 21:20:51 · 494 阅读 · 0 评论 -
HDU1548 A strange lift 最短路
#include#include#include#includeusing namespace std;int first[210],next[403],n,s,t,d[210];struct node{ int u,v,w;}edge[403];typedef pairpii;priority_queue,greater >p;void dj(){ d[s]=0;原创 2014-08-01 21:58:24 · 354 阅读 · 0 评论 -
情人节专场 B题 最短路
B. Greg and Graphtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGreg has a weighed directed graph, consis原创 2014-08-02 15:18:42 · 382 阅读 · 0 评论 -
hdu I Hate I t线段树
小试线段树。原创 2014-07-31 09:49:53 · 238 阅读 · 0 评论