摘要: #include<iostream>#include<cstdio>#include<cstring>using namespace std;int map[21][21];int a[21][21];bool used[21][21];int n,m;bool dfs(){ int i,j; int x,y,r; int flag=0; for(i=1;i<=n;i++) { if(flag) break; for(j=1;j<=n;j++) if(!used[i][j]) { ... 阅读全文
posted @ 2012-04-24 09:34 静静的等待_93 阅读(377) 评论(0) 推荐(0) 编辑
摘要: View Code 1 #include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 using namespace std; 5 int n,m; 6 char s[1000010],p[10010]; 7 int next[11111]; 8 void get_next() 9 {10 next[0]=-1;11 for(int i=1,j=-1;i<m;i++){12 while(j>=0&&p[j+1]!=p[i]) j=next[j];13 if(p[j+1]== 阅读全文
posted @ 2012-03-20 18:33 静静的等待_93 阅读(117) 评论(0) 推荐(0) 编辑
摘要: View Code 1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio> 4 using namespace std; 5 int a[10001],cnt; 6 bool cmp(int a,int b){ 7 return a<b; 8 } 9 int sch(int u)10 {11 int low=0,high=cnt-1,mid;12 if(u<=a[low]) return low;13 else if(u>=a[high]) return high;14 w 阅读全文
posted @ 2012-03-20 16:01 静静的等待_93 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 我的wa代码 wa到吐血,找不到错。View Code 1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio> 4 using namespace std; 5 __int64 num[1000000],sum,cnt; 6 const __int64 maxn=1000000000100; 7 void dfs(__int64 u,__int64 d) 8 { 9 if(d>12) return;10 dfs(num[sum++]=u*10+4,d+1);11 dfs(num[sum 阅读全文
posted @ 2012-03-19 22:58 静静的等待_93 阅读(277) 评论(0) 推荐(0) 编辑
摘要: dpView Code 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 const int maxn=10010; 6 int dp[11][10010]; 7 int belong[10010]; 8 int w[10010],v[10010]; 9 int flag[20];10 int main()11 {12 int n,m,k,i,j,x;13 while(scanf("%d%d%d",&n,& 阅读全文
posted @ 2012-03-19 08:22 静静的等待_93 阅读(301) 评论(0) 推荐(0) 编辑
摘要: View Code #include<iostream>#include<cstdio>#include<cstring>using namespace std;int len[501];int a[501],b[501];int main(){ int cas;int n,m; scanf("%d",&cas); while(cas--) { memset(len,0,sizeof(len)); scanf("%d",&n); for(int i=1;i<=n;i++) scanf(" 阅读全文
posted @ 2012-03-18 19:57 静静的等待_93 阅读(236) 评论(0) 推荐(0) 编辑
摘要: View Code 1 #include<iostream> 2 #include<cstdio> 3 #define inf 0x7ffffff 4 using namespace std; 5 int x,y,z,r; 6 int lx,ly,mx,my,nx,ny; 7 void work() 8 { 9 lx=max(lx,x);10 ly=min(ly,x+r);11 mx=max(mx,y);12 my=min(my,y+r);13 nx=max(nx,z);14 ny=min(ny,z+r);15 }16 int main()17... 阅读全文
posted @ 2012-03-18 19:05 静静的等待_93 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 2-satView Code 1 #include<iostream> 2 #include<vector> 3 #include<cstdio> 4 #include<cstring> 5 using namespace std; 6 const int MAX = 20010; 7 int n,m,T; 8 vector<int>mp[MAX]; 9 int st[MAX];10 int dfn[MAX],low[MAX];11 int top,btype,tdfn;//btype:连通块的个数12 int belong[MAX] 阅读全文
posted @ 2012-03-17 17:43 静静的等待_93 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 2-sat 只需要简单建图即可。View Code 1 #include<iostream> 2 #include<vector> 3 #include<cstring> 4 #include<cstdio> 5 #include<algorithm> 6 using namespace std; 7 const int maxn=20001; 8 vector<int>edge[maxn]; 9 int st[maxn];10 int dfn[maxn],low[maxn];11 int top,btype,tdfn;1 阅读全文
posted @ 2012-03-17 16:26 静静的等待_93 阅读(204) 评论(0) 推荐(0) 编辑
摘要: 新手学习2-sat算法,看了一个多小时,才看懂。然后类比着打代码,结果出来和网上的一样。。。不过这一题可以作为有向图缩点的模板,同时也可以比较清晰的理解2-sat的内涵,所以在这里仍然贴出来。View Code 1 #include<iostream> 2 #include<vector> 3 #include<cstring> 4 #include<cstdio> 5 #include<algorithm> 6 using namespace std; 7 const int maxn=20001; 8 vector<int& 阅读全文
posted @ 2012-03-17 15:48 静静的等待_93 阅读(418) 评论(0) 推荐(0) 编辑