• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
 






Siriuslzx

 
 

Powered by 博客园
博客园 | 首页 | 新随笔 | 联系 | 订阅 订阅 | 管理
上一页 1 2 3 4 5 6 7 8 9 10 ··· 12 下一页

2012年8月29日

poj - 2676 Sudoku
摘要: 经典的搜索题,我用的是简单的暴搜,其实这题用排除法做会更快。 1 #include <stdio.h> 2 #include <string.h> 3 #define index(a,b) 3*(a/3)+(b/3) 4 bool r[10][10],c[10][10],sodu[10][10]; 5 int map[10][10]; 6 bool find; 7 void dfs(int n) 8 { 9 int i,j,k,x,y;10 if(find) return ;11 if(n >= 81)12 {13 find = 1;14 ... 阅读全文
posted @ 2012-08-29 00:22 Siriuslzx 阅读(145) 评论(0) 推荐(0)
 
poj - 3630 Phone List
摘要: 同poj 1059,判断是否为前缀。 1 #include <stdio.h> 2 #include <string.h> 3 const int N = 100000; 4 int next[N][10],cnt=0; 5 bool f=1,end[N],vis[N]; 6 void inst(char *s) 7 { 8 int u=0,p; 9 for(;*s;s++)10 {11 p = *s - '0';12 if(end[u])13 {f = 0; return ;}14 if(!next[u]... 阅读全文
posted @ 2012-08-29 00:19 Siriuslzx 阅读(158) 评论(0) 推荐(0)
 
poj - 1056 IMMEDIATE DECODABILITY
摘要: 字典树问题,判断一个串是不是另一个的前缀。 1 #include <stdio.h> 2 #include <string.h> 3 int next[1000][2],cnt=0; 4 bool f=1,end[1000],vis[1000]; 5 void inst(char *s) 6 { 7 int u=0,p; 8 for(;*s;s++) 9 {10 p = *s - '0';11 if(!next[u][p])12 {13 cnt++;14 next[cnt][... 阅读全文
posted @ 2012-08-29 00:16 Siriuslzx 阅读(180) 评论(0) 推荐(0)
 
poj - 1509 Glass Beads
摘要: 求字符串循环同构中字典序最小的,用最小表示法做的。 1 #include <stdio.h> 2 #include <string.h> 3 const int N = 10010; 4 char s[N]; 5 int main() 6 { 7 int n,i,j,k,t,l; 8 scanf("%d",&n); 9 while(n--)10 {11 scanf("%s",s);12 l = strlen(s);13 i = k = 0; j = 1;14 while(i<l && j<l & 阅读全文
posted @ 2012-08-29 00:13 Siriuslzx 阅读(145) 评论(0) 推荐(0)
 
poj - 2503 Babelfish
摘要: 简单字典树。 1 #include <stdio.h> 2 #include <string.h> 3 const int N = 200000; 4 int nxt[N][26],word[N]; 5 char eng[N/2+10][11]; 6 bool end[N]; 7 int cnt,cur,p,f; 8 void insert(char *t, char *s) 9 {10 cur = 0;11 while(*t)12 {13 p = *t - 'a';14 if(!nxt[cur][p])15 {16 ... 阅读全文
posted @ 2012-08-29 00:09 Siriuslzx 阅读(163) 评论(0) 推荐(0)
 
poj - 1236 Network of Schools
摘要: 强连通分量题,涉及求强连通分量和缩点,基本是抄的模板,我也是把这题的代码当模板放这里。做这题的一个收获,缩点后为构造强连通分量,最少要添加几条有向边:统计入度和出度为0的点的数量,取其大者。 1 #include <stdio.h> 2 #include <string.h> 3 #include <vector> 4 using namespace std; 5 const int N = 105; 6 int stk[N],col[N],dep[N],low[N]; 7 int cnt,cols,top,ans1,ans2; 8 bool inq[N]; 阅读全文
posted @ 2012-08-29 00:07 Siriuslzx 阅读(136) 评论(0) 推荐(0)
 
poj - 3786 Repeater
摘要: 一道递归构造图形的题,做的时候一直TLE,多想想优化才过的。 1 #include <stdio.h> 2 #include <string.h> 3 char map[2500][2500]; 4 char tplt[6][6]; 5 int n; 6 void build(int m, int x, int y) 7 { 8 int i,j,sum = 1; 9 for(i = 1; i < m; i++) sum *= n;10 if(m == 1)11 for(i = x; i < x+n; i++)12 for(j = ... 阅读全文
posted @ 2012-08-29 00:01 Siriuslzx 阅读(183) 评论(0) 推荐(0)
 

2012年8月28日

poj - 1325 Machine Schedule
摘要: 先写下几个术语,以后忘了就来找:点覆盖集:点“看住”边。点支配集:点“看住”点。独立集:没有公共点的边 or 没有公共边的点。这是我个人的理解,通俗就好。两个结论:最小点支配集 == 全集 - 最大独立集; 二分图中,最小点覆盖集 == 最大二分匹配。这题是求最小点覆盖集的,做这题时我才知道上面的结论,怎么证明我就不会了。 1 #include <stdio.h> 2 #include <string.h> 3 #define N 105 4 #define E 1010 5 int b[N],m,n; 6 int fst[N],next[E],v[E]; 7 bool 阅读全文
posted @ 2012-08-28 23:59 Siriuslzx 阅读(163) 评论(0) 推荐(0)
 
poj - 1469 COURSES
摘要: 简单二分匹配,检查是否能完全匹配。这里面的代码并不很好,有改善空间。 1 #include <stdio.h> 2 #include <string.h> 3 #include <vector> 4 using namespace std; 5 const int N = 310; 6 int P[N],C[N],n,m; 7 bool vis[N]; 8 vector <int> next[N]; 9 bool SearchPath(int u)10 {11 int i;12 for(i = 0; i < next[u].size(); 阅读全文
posted @ 2012-08-28 23:44 Siriuslzx 阅读(142) 评论(0) 推荐(0)
 
一点感想
摘要: 我对写博客的态度一直不好,经常做了题也不写题解,直到今天吃亏了。“书到用时方恨少”,今天想找一个我以前写的代码,打开博客却发现没有,只好绕远路去OJ上找,还要再根据代码思考自己当时是怎么想的。于是我才明白,作为一个菜鸟,我的博客不是给别人看的,而是给我自己看的。思路是要写出来的,不然以后还要重新想一遍。抓紧补吧。 阅读全文
posted @ 2012-08-28 23:34 Siriuslzx 阅读(121) 评论(0) 推荐(0)
 
上一页 1 2 3 4 5 6 7 8 9 10 ··· 12 下一页